Can't get arduino to read past the first serial input

Hey all,

I am trying to control the operation of a DC motor by sending serial commands to the arduino using a python script.

I am able to get the first serial input read fine (which turns the motor on), but can’t seem to get the the arduino to read a second serial input properly from the python script to turn the motor back off as well.

The codes are in the attachments, for some reason I was getting cloudflare blocked when trying to paste it in directly :confused:

I have tried many different variations of trying to clear the serial input buffer before sending the second serial write via python but nothing seems to be working. Wondering if I’m missing something else or if my program just needs something extra added that I dont know about.

Thanks for the help!

Arduino Script.PNG

You should output the contents of the data you're receiving to the arduinos serial monitor to double check that its not ever receiving the second value. If you do it let me know what it says and I will be happy to continue help debugging

@Wallwin, please don't post pictures of code. Just include the code in your next Reply or add it as an attachment. See How to use the Forum

In the meantime have a look at this Simple Python - Arduino demo


Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: