i am a beginner at python and I am average at Arduino and I had the idea of using both of them together for a project. I have been trying to make a Arduino + Python car which I can control with my computer. I have used Pyfirmata and the code seems perfect to me. When I run the code from CMD i have a weird bug/issue. I have uploaded Standard Firmata to the arduino UNO. I get no errors while uploading or running its just that its output is messed up.
Here's the Python Code:
from pyfirmata import Arduino, util import time board = Arduino("COM3") MotorLeft = board.get_pin('d:10:o') # Assigning output to PIN MotorRight = board.get_pin('d:11:o') # Assisging output to PIN play = True while play: control = input( print("Enter W, A or D to move forwards, left or right. Enter 0 to exit")) if control != 0: if control == "W" or "w": MotorRight.write(1) MotorLeft.write(1) time.sleep(1) MotorRight.write(0) MotorLeft.write(0) if control == "A" or "a": MotorLeft.write(1) time.sleep(1) MotorLeft.write(0) if control == "D" or "d": MotorRight.write(1) time.sleep(1) MotorRight.write(0) else: print("Invalid Commmand") else: print("Exited Succesfully") play = True
Currently I have not built the car, I am using a pair of LEDs to do what the motors function and to test out the code.
Here is the link for the output video. I entered "W" which should ideally turn on both of the LEDs however, both of them turn on then off and then turn on off one by one.