Can you execute Arduino programs from PySerial?

Hi, I'm trying to use an arduino sketch I coded as part of a larger program that's based in python. I want to use PySerial to interface with the arduino, and have a dedicated GUI that enables a user to simply click a button, and execute the arduino code, while reading the data from python.

Is this feasible? I'm a bit confused about the nuances of pyserial, and haven't been able to find out if this type of feature is even supported by the serial library.

Thanks in advance for your help :slight_smile:

Is this feasible

No.

You could send the Arduino a message that told it to call a function however.

If the arduino sketch is already uploaded onto the board, could the python GUI somehow toggle it on and off/reset it?

Also any ideas to accomplish this? Apologies, I'm very new at this.

If the arduino sketch is already uploaded onto the board, could the python GUI somehow toggle it on and off/reset it?

No

Also any ideas to accomplish this?

I told you how in reply#1, you need to be in control of both ends.

Your Python program needs to send a message to the Arduino program and the Arduino program needs to know what do do when a message is received. A message could be (ideally should be) as short as a single character.

This Python - Arduino demo may be of interest.

Also have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R