I'm trying to command two motors connected with a l298n module from a RPI4. This is not working on node.js but the same script (sort of porting) in python works because motors run.
Python script:
import RPi.GPIO as GPIO
from time import sleep
in1 = 24
in2 = 23
en = 25
GPIO.setmode(GPIO.BCM)
GPIO.setup(in1,GPIO.OUT)
GPIO.setup(in2,GPIO.OUT)
GPIO.setup(en,GPIO.OUT)
GPIO.output(in1,GPIO.LOW)
GPIO.output(in2,GPIO.LOW)
p=GPIO.PWM(en,1000)
p.start(25)
while(1):
GPIO.output(in1,GPIO.HIGH)
GPIO.output(in2,GPIO.LOW)
JS script (maybe not interesting, launched with sudo):
var Gpio = require('pigpio').Gpio;
const in1 = new Gpio(24, {mode: Gpio.OUTPUT});
const in2 = new Gpio(23, {mode: Gpio.OUTPUT});
const en = new Gpio(25, {mode: Gpio.OUTPUT});
in1.digitalWrite(0);
in2.digitalWrite(0);
en.pwmWrite(255);
setTimeout(function(){ console.log("finish"); }, 10000);
pigpiod -v gives me version 71
Where is the problem? (PS: i started with https://www.npmjs.com/package/motor-l298n but when found that motors were not working i tried to go directly with pigpio). The project is in JS so python script is just to check that things works. Thanks