As you may remember, we enabled the serial port on the Raspberry Pi earlier. We are now going to install a Python library called PySerial that allows us to communicate via Python.
This can be installed via apt-get
:
sudo apt-get install python-serial
Tip
If you already have the latest version of the library, you will see this message:
python-serial is already the newest version.
Once you have this installed you can read more about the library at the PySerial website: https://pythonhosted.org/pyserial/.
Before we start writing applications with PySerial, we need to know where our Arduino is connected. You may have noticed that this information was provided in the Arduino IDE when you selected the serial port. If you used a different machine to write the sketch, however, there is a method we can use to find out where it is plugged in.
Start by running the following command:
ls /dev/tty*
This will output a list to your screen. Currently, the Arduino Uno isn't connected,...