GPIO - ON/OFF using Config.txt

Greetings,

I am trying to switch ON a GPIO using Config.txt
(A LED will be connected to the GPIO pin so that it will switch ON when the OS boots up and switches OFF when the OS is shutdown )
Can someone tell me the correct syntax for doing it ?

Thanks in advance.
Velind.

Comments

  • edited June 13

    Using a shell script you can do this:

    echo 1 > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio1/direction
    chmod 666 /sys/class/gpio/gpio1/value
    echo 1 > /sys/class/gpio/gpio1/value
    

    Naturally, you can dot his for any GPIOx pin. For inputs, set the direction to "in".

  • Thanks for the quick response.
    For using GPIO 23, is the below syntax correct ?

    echo 1 > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio23/direction
    chmod 666 /sys/class/gpio/gpio23/value
    echo 1 > /sys/class/gpio/gpio23/value

  • Almost. The first line should be echo 23 > ... . To clarify, the last line sets the pin to high, to revert that echo 0 to it.

Sign In or Register to comment.