Uses the libgpiod library to control a small Direct Current motor with Raspberry Pi 4 or 5
The Raspberry Pi can deliver a small amount of current and voltage to power light circuits. Using the internal power of the Raspberry Pi to provide too much amperage or voltage to a motor can cause issues such as: 1) destroying a chip on the Raspberry Pi motherboard, 2) cause the power surge to reboot the Raspberry Pi, or 3) corrupt the OS or program due to low voltage. The way to prevent this from occurring is to use a transistor.
The lgpio library can be installed Raspberry Pi OS (6 July 2023) and instructions are available at http://abyz.me.uk/lg/download.html
Install instructions are:
- install Raspberry Pi OS (64-bit)
- Open a terminal and type the following commands:
- sudo apt install swig python3-dev
- sudo apt install python3-setuptools
- sudo apt-get install libunwind8
- wget https://github.com/joan2937/lg/archive/master.zip
- unzip master.zip
- cd lg-master
- make
- sudo make install
- create a Motor example program and copy the program and libraries to the RaspberryPi Desktop
- give the executable permission to run with something like: 'sudo chmod +x NPNMotor'
- run the program with something like: 'sudo ./NPNMotor'