L298N motor driver problem with Pyfirmata

Hello I am having a problem with my L298N motor driver. I want to use Pyfirmata to control my driver but even after experimenting, researching and implementing it is not working. I want the Pin 1 and 2 to be activated by a command. So what's the command(in python)? Here is the code:

import pyfirmata

Board = pyfirmata.Arduino('COM4')

m1p1 = Board.get_pin('d:5:o')

m1p2 = Board.get_pin('d:4:o')

m1p1.write(1)

m1p2.write(1)

print("Done!")

Pin layout:

Input1 = pin5
Input2 = pin4
input3 = pin 3
input4 = pin4
5v = 5v
GND = GND
Output1 = Motorpin1
Output2 = Motorpin2

What's the recommended voltage and current of your motor?

It's a small dc motor probably 1.5V to 3V. But at 9v it just goes crazy fast

How did you wire all the input pins of the driver?

Hello @DrDiettrich thanks for you help. I have figured out the problem myself. I set both Output1 and Output2 to High thus they were cancelling each other

Hello again, I just wanted to ask 1 more question. Usually to control the speed of the motor through a motor driver you have to use the enable pin, and in the code you write this analogWrite(9, 100)
. So if I want it to do the same thing just using Pyfirmata what will be the code.
Thanks.

Sorry, that's none of my programming languages :frowning:

I want to ask @arnav_swaraj which Programming language is this?

Pyfirmata uses python

It's python

Please help

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.