Page 1 of 1

GPIO LEDS

Posted: Mon Jan 15, 2018 9:56 am
by sind
Hello,

I need to control the 2 GPIO LEDS in Linux.
Is necessary a specific driver to control them or I can simply control the GPIOs from "/sys/class/gpio"? If so which GPIOs are connected to the LEDS?

Regards

Re: GPIO LEDS

Posted: Thu Jan 18, 2018 9:51 am
by tamir
In Linux kernel GPIOs related to the north part of the SOC numbered from 434:
GPIO_1 = 435
GPIO_2 = 436
GPIO_3 = 437
GPIO_4 = 438

You’ll Need to work as root (root password required):
$ su
Password:

To control gpio435 (GPIO_1, DS3 green LED on fitlet2):
$ echo 435 > /sys/class/gpio/export
$ echo out > /sys/class/gpio/gpio435/direction
$ echo 1 > /sys/class/gpio/gpio435/value
# DS3 green LED should be GREEN now
$ echo 0 > /sys/class/gpio/gpio435/value
# DS3 green LED should be OFF now
$ echo 435 > /sys/class/gpio/unexport

The GPIO framework and GPIO sysfs interface are documented in
https://www.kernel.org/doc/Documentation/gpio/gpio.txt