A simple example showing how to communicate with an Arduino from a Python script running on a PC. It demonstrates a very simple protocol, and how to use the protocol to talk to an Arduino over a serial port.
Requirements:
- Any Arduino board. (Tested with Uno, Nano, Leonardo)
- The Arduino IDE
- Python 3.8+
- make (optional)
Download and install the Arduino IDE. Open the arduino.ino sketch in this folder.
Install bakelite and pyserial.
$ pip3 install bakelite pyserial
The required source files have been pre-generated for this project. If you'd like to make changes to proto.bakelite, run:
$ make
Next, use the Arduino IDE to compile and upload the code to your Arduino board. Find the com port (Windows) or device (Linux/Mac) your board is connected to and run:
python3 ./test.py [port/device]