Joystick widget merged node js equivalent

Does anybody know the equivalent of this code (shown below) in Node JS?
Been searching around for an example but no cigar.
This is for my continued quest to try to control a couple of motors with Raspberry pi + node js using Blynk joystick widget.

Thank you in advance.

Smoking is bad for you anyhow… try this link instead :stuck_out_tongue_winking_eye:

No, it is not the using Merge option… but that option might not have been built into the NodeJS library, as many other things aren’t.

That code was actually my guide to making the code below work however it’s nowhere close to complete as it just moves the rover forward and nothing else. Right now my main issue is when the joystick is centered with “AUTORETURN”, it continues to send PWM values and engaging the motors. This is because center is not 0. Do you know by any chance how to have the joystick send 0 at center?

const Blynk = require('blynk-library');

const AUTH = 'xxxxxxxxxxxxxxxxxxxxxxxxx';

var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr: 
"", port: 8080 } ) });

const Gpio = require('pigpio').Gpio;

const forwardR = new Gpio(27, {mode: Gpio.OUTPUT});
const forwardL = new Gpio(10, {mode: Gpio.OUTPUT});

var JoyY = new blynk.VirtualPin(24);  //Forward

JoyY.on('write', function(forwardLValue) {

JoyY.on('write', function(forwardRValue) {  

With C++ I would use map() Try Googling for the JS equivalent

Or use JS equivalent of if() statements… Assuming 0-1023, if <= 511 go reverse or if >= 512 go forward.

Basically it seems your issue is JS coding, not Blynk.

And I haven’t tried this lately, so thought of it last… but why not change the MIN / MAX settings in the Widget to something like -100 / 100 Then you can use 10 to 100 for forward and -10 to -100 for reverse… with a small buffer of -10 to 10 around 0 (AKA Center) for full stop.

I did exactly that (-100 to 100) right before posting above rudimentary code but I was never able to figure out how to have Node JS interpret those values on the raspberry pi side. This is why I was looking into the merging option in joystick as I saw someone else do it this way but in C and which is why the image I posted earlier has those values.

I like your idea of mapping out a range of 10 to 100 for forward and -10 to -100 for reverse. After I have node JS interpret these values (I will have figure out how to do this), I would then also need to convert to PWM values of 0-255 as that’s what pigpio is expecting in order to control the motor driver.

Just set the widget for -255 / 255 and have your code determine if the value is negative or positive for the direction pin, assuming your motor driver works that way.