Using Python to test robot motors
Before we get stuck in and do fancy things with the motors, we need to get them set up and test them. This way, we can make sure they work and iron out any problems.We need to download the library to work with the motor board we have chosen. Many robot parts, apart from the simplest ones, have an interface library to control the motors and other devices on the board. We’ll use pyinfra to install it.
Preparing libraries
We are going to set up the I2C bus and Python libraries for the Inventor HAT Mini.The Raspberry Pi uses I2C to connect to this Inventor HAT Mini. I2C buses let you send and receive data and are flexible, so you can connect many devices to the same bus.Let’s start with I2C in the file deploy/configure_pi.py:
from pyinfra.operations import server
server.shell("raspi-config nonint do_i2c 0", _sudo=True)
This uses a server.shell operation to run the raspi-config tool, which configures Raspberry Pi hardware and boot...