0
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 Respostas
+ 1
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).
+ 1
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
https://code.sololearn.com/cA35a4a24A16/?ref=app
and here is the code i’m running from my pi
https://code.sololearn.com/cai37dUufMGP/?ref=app
The delays could definitely be a possibility, but tbh i’m not too experienced working w/ the arduino.