arduino communication via the serial port | Sololearn: Learn to code for FREE!


arduino communication via the serial port

I’ve been working on a robot. The motors are drive via an adafruit motor driver on an arduino uno r3. I’m working on controlling it from my raspberry pi using python. When I connect via the serial port from the python shell I can send my commands, in this case “Forward”, “Reverse”, “Stop”, “Left”, and “Right”. But, when I put the exact same code into a file, it doesn’t work properly. It runs the code without any errors, but it should in the case of the code, go forward for 2 seconds, and then stop. I’m using PySerial to communicate with the arduino. Any suggestions as to what might be my issue would be very much appreciated! :)

2/20/2021 2:31:05 AM


2 Answers

New Answer


can you post the code? i have a slight suspicion that either you forgot to import something in the file that you did in IDLE, or the delays are not placed right. use code playground to do so (dont be offended if you know code better than i thought you did. ive seen some weird things just a moment ago).


No offense taken, for all I know I could have just screwed up some imports, although I dont think I did. Here is the code that is on the arduino and here is the code i’m running from my pi The delays could definitely be a possibility, but tbh i’m not too experienced working w/ the arduino.