For a more in-depth guide, we've created a detailed tutorial hosted on GitHub. In this tutorial, you'll find step-by-step instructions, code examples, and additional resources to help you better understand and implement the concepts discussed here. Whether you're a beginner or looking to deepen your knowledge, this comprehensive guide covers everything you need.
You can access the GitHub repository with the full code here: https://github.com/System-Electronics/astrial_tutorials/tree/main/02-rgb_led_blink_waveshare
PremiseIn this tutorial we are going to use the three Waveshare carrier boards provided in the components section.
These boards have all the same pinouts and the steps required to make the RGB LED blink are the same hence we are going to refer to the boards simply as CM4.
The CM4 PoE Board can be powered like the other boards via the USB-C port but also via the ethernet port by using a PoE injector (like the one in the image below).
- Connect the Astrial module: connect the Astrial’s ground to any CM4’s ground pin, and Astrial’s VCC to any CM4’s 5V pin. For this tutorial we have used pins 2 and 6 as 5V and GND respectively.
- Connect the RGB led: connect the led’s ground pin (the longest pin) to any Astrial’s ground pin. For this tutorial we have used pin 20. Connect the red, green, and blue pins of the led to pins 22, 18 and 16, corresponding to GPIOs 25, 24 and 23 respectively.
Take a look at the schematics and the image below to have a clear view of the connections.
- Install the python packages: use the pip command line tool to install the required library to control the GPIO pins of your board. Open a terminal window and run the following command:
pip3 install gpiod==2.2.0
- Create the python script: create a python script that implements the code provided in the Code section of this article.
- Launch the python script: we are finally ready to launch our python script. From the terminal, run the following command:
python3 rgb_led_blink.py
If you have done everything correctly, you should see the RGB LED changing color at regular intervals.
Comments