pyFirmata
Getting started...
Getting started...
There is a limitation for pyFirmata to work, you MUST be connected to a computer, but great to experiment with in the Lab.
I used an Arduino Uno.
Before you are able to get this to happen, you will need to prepare:
Install the pyfirmata module for Python to recognize the function calls. To do this, run Pip in the Windows Admin Powershell: pip install pyfirmata
Install the Arduino Firmata firmware onto the Arduino. To do this, run the Arduino software, then select the following menus: File>Examples>Firmata>StandardFirmatad then click the Upload button to install the firmware.
Exit the Arduino software and reboot your Arduino board, (unplug and replug in).
Open Idle on your computer, and go File, new file.
Copy the code in this image, then Save the file and run it.
The path to the file will be different and reflect your file location on your computer. If you get any red error messages, the the pyFirmata module in not installed correctly.
Edit your Python file in Idle and add the last line, the COM number will be the one your computer has assigned to Arduino board. This can be found by looking in your Device Manager under Ports.
Edit your Python file in Idle and add the next section shown on the right.
(Also "import time" just after the try/except part.)
This will turn on the on board LED for one second, then turn it off again.
The following line is the one that configures the LED (creates a variable called "LED"):
LED = board.get_pin('d:13:o')
This information was based on the following YouTube: https://youtu.be/RS35q6ksU6w Dec 2018
Also documentation from: https://pyfirmata.readthedocs.io/en/latest/