I have seen a few questions recently where Forum members were enquiring about controlling an Arduino with a PC GUI program.
With the zeal of the newly converted I thought that others might be interested in the attached simple Python GUI program for controlling an Arduino. I do realize that this is more of a Python tutorial than an Arduino tutorial.
The GUI interface looks like this
The buttons allow you to switch on or off a couple of LEDs and the slider allows you to move a servo.
When the program starts it allows you to select the serial port for the Arduino. I have only tested this on Linux. It would be great if someone would try it on Windows or on a Mac.
The purpose of the Python code is simply to provide all of the parts for a simple working example as a starting point for whatever else someone may wish to do.
Apologies to anyone who is a Python expert and doesn’t like my coding style. I understand it and I think it will be easily accessible to Arduino programmers.
The Python code for communicating with the Arduino is in the file arduinoComms.py and is very similar to my previous example here.
To try the example you need to save the two python files into a suitable directory and run it with python arduinoGUI.py (after uploading the Arduino code, of course).
By the way this demo does not receive data from the Arduino after startup. I may produce an
extended version that does - now in Reply #3
Edit to add …
The attachments seem to have been lost in the Upgrade on 20 Oct 2014.
I have added a zip file with the files as it won’t accept any other file type. …R
PythonArduinoGUI.zip (3.42 KB)
ArduinoGUICode.ino (2.98 KB)
arduinoGUI.py (2.49 KB)
arduinoComms.py (2.88 KB)