GPIO Powered Light

Has anyone tried powering an LED via the GPIO yet? Looks fairly standard, +3.3v pin, Ground pin, and a resistor. The only thing i’m unsure of is actually controlling it on and off. Ideally i’d like to use a python script as the results of a query should be powering this light on and off.

Well, I may have answered my own question just now. 5B documentation says the libmraa library is supported, seems as if they have python bindings to interact with the GPIO.

Guess i’ll just have to try it.

Okay so has anyone successfully installed libmraa on the 5B? The radxa page doesn’t exist and following the guides I have found also proves to not work.

Try this website below, I found it useful
https://osoyoo.com/2022/07/20/rock-pi-4-gpio-control/

I have a rock-3c and used same digital pins as sample program, and changed gpio numbers to what these were for the rock=3c.

Thank you. Guess I need to get a light now, I believe if I use pins 1 and 17 paired to the R & G of an RGB light I should be able to trigger red and green using this.

The pin connections are different with each rockpi below are what I used.

rock-4c+ pin connections:-
LED_Pin=73 #GPIO pin 73 physical pin 31
Button_Pin=154 #GPIO pin 154 physical pin 16

rock-3c pin connections:-
LED_Pin=108 #GPIO pin 108 physical pin 31
Button_Pin=105 #GPIO pin 105 physical pin 16

if you are running “sudo python3 rockblink.py” it should run ok.
if you are running in thonny, you will get permission errors.
to overcome that problem you have to give some permissions

sudo usermod -aG i2c <user_name> #may not be needed this I was trying to use i2c to control PCA9685 servo driver

sudo groupadd -f -r gpio
sudo usermod -a -G gpio <user_name>

cd ~
sudo nano 99-com.rules

Add this line to file all on single line to file 99-com.rules and save

SUBSYSTEM==“gpio*”, PROGRAM="/bin/sh -c ‘find -L /sys/class/gpio/ -maxdepth 2 -exec chown root:gpio {} ; -exec chmod 770 {} ; || true’"

Then copy to/etc/udev/rules.d/

sudo cp 99-com.rules /etc/udev/rules.d/

add these commands

cd ~
sudo su
sudo udevadm control --reload-rules && udevadm trigger

sudo reboot

After reboot you should be good to go
hope this helps.

Yes, looking at the rock5b layout, 1 and 17 are +3.3v which is what I need, Ground shouldn’t matter. I see what you are saying though.

From the rock5b layout
pin 16 is gpio number 100
pin 31 is gpio number 47
these are the ones you require for the sample programs

1 Like