Loading

MakerBot Print is our newest print-prepration software, which supports native CAD files and STL assemblies,
allows you to interact with all your printers via the Cloud, and many other exciting new features.

Download Now

L298n motor driver with Blynk

Please Login to Comment

Hi, I could use some help with getting my project to work. What I want to do is control 2 DC motors with an L298n driver and a Raspberry Pi 3 from my phone via Blynk. I also want to control the motors with the joystick widget in the Blynk app. I got my Pi connected to my phone over wifi with Blynk, but I am having trouble getting the Python for the joystick to control the motors with the driver. If you could point me in the right direction it would be much appreciated.

Sorry for the very late response. I ended up using 4 buttons in python instead of the joystick. It works great with the driver. The script is posted:)

please do let us know! Im getting a raspberry pi 3B next week and plan to use blynk and probably one of those motor controllers as well.

Thanks for all the replies! Ill work on it and let you know if I get it working

i have worked a bit with blynk and arduino in the past. they have some good examples on there site and ready to use code for a lot of stuff. Like franciscorp said you should try to get the motors working without blynk first. Then try to figure out how the joystick works. And then write the code that takes data from the app and controls the motors. For the joystick you probably want to output onto so called virtual pins. Those can be used in your code to get the data from teh joystick. The link below is a example from blynk with the joystick:
https://examples.blynk.cc/?board=Raspberry%20Pi&shield=System%20default&example=Widgets%2FJoystickTwoAxis

Hello,

I don't know anything about Blynk, but by looking at the examples on it's site, I think you should get something by using the forward/reverse functions from this sample python code: https://www.instructables.com/id/Raspberry-PI-L298N-Dual-H-Bridge-DC-Motor/
inside the "BLYNK_WRITE" function of this example:
https://examples.blynk.cc/?board=Raspberry%20Pi&shield=System%20default&example=Widgets%2FJoystickTwoAxis

Thanks! I don’t suppose you know how to interface it with a L298n motor driver?

Never done it, but I would follow this steps:
1- Review the first link and try to get the motors working with the raspberry pi.
2- Once you have a working code that spins the motors (and since you want to use a joystick), write a function that receive positive or negative x and y values and convert that to forward/reverse spin of each motor. (assuming these are the values received on the x/y variables on the Blynk example)
3- Include your code on the Blynk example source code and call your functions inside the "BLYNK_WRITE" function passing "x" and "y" variables as arguments.

PS I'm assuming that the Blynk example script is also run by a python interpreter.
PPS This code converts x/y coordinates to motor movement, it could be useful: https://github.com/CoretechR/ZeroBot/blob/master/app.js