✌️Using the GPIO – Rock 4SE 🤘

One of the main uses for single-board computers like the Rock 4SE is to control things through the GPIO pins. This can be simple LED control or complete motor or servo control. SBCs have long been used in robotics of all sorts – from simple four-wheeled robots to complex multi-jointed two-legged auto-balanced robots.

The GPIO pins in the Rock 4SE will allow you to use the board in the same fashion and hopefully will allow some code to be reused with minimal effort.

I have only just started testing the GPIO, but through the instructions on the WIKI (here) I was able to get an LED fading through the use of PWM.

From the installation instructions, the only library I needed to install when using the provided Bullseye Debian image was:

rock@rockpi-4b: sudo apt install libmraa

I then needed to enable PWM on the pins

rock@rockpi-4b: sudo nano /boot/hw_intfc.conf

Then just edit two lines of code

# Set "on" to enable the optional hardware interfaces while set "off" to disable.

intfc:pwm0=on
intfc:pwm1=on

I rebooted after making these changes and connected an LED to pin 11 and edited the sample python code

cd /usr/local/share/mraa/examples/python/
sudo nano pwm.py
# initialise PWM
x = mraa.Pwm(11) # Chhanged to Pin 11

Then I just ran the code:

sudo python3 pwm.py

And the LED started blinking!

An LED connected to a Breadboard fading from bright to dim.

So, thankfully nice and simple! and looks like it should be possible to convert code samples between RPi.GPIO and MRAA without much issue.