I'm a newcomer to this kind of tinkering so please bear with me here. I've searched high and low for an answer but have been unable to find one. I have a Raspberry Pi Zero W hooked up to a L298N motor controller and want to turn a motor forward or backward using Johnny Five. Oddly enough, when I do a simple trial of simply instantiating the motor via script, it begins turning without instruction and won't stop until I reboot the Pi; even killing the script doesn't stop the motor once it's started. Here's the code I'm using which starts the motor:
const raspi = require('raspi-io').RaspiIO
const five = require('johnny-five')
const board = new five.Board({
io: new raspi()
})
board.on('ready', function () {
const motor = new five.Motor(['GPIO23', 'GPIO24'])
})
That's it. the new five.Motor
call is the one that starts the motor going.
Script/lib info:
NodeJS: v10.15.0
"johnny-five": "^1.4.0"
"raspi-io": "^11.0.0"
And, an image describing my wiring:
I have the L298N using 5v power from the Pi board, ground connected, and the in1/in2 is hooked to GPIO23 and GPIO24.
If I run the script with GPIO23 connected but not GPIO24, the motor does not run. If the opposite is true (GPIO24 connected but not GPIO23), then the motor runs on startup.
It seems like what I'm trying to do is very simple, but I also understand that I'm at the mercy of two libraries (raspi-io and johnny-five) that I may not be using properly. I've tried my best to follow all examples I could find (especially This one and pared my code back to the bare minimum to still create this effect. Any help would be greatly appreciated.