RGB LED on Expansion Dock



  • I was looking around for information on the GPIO connected to the RGB LED on the expansion dock, didn't find any, so I tried to traced back using a multimeter. Below is the connection, please correct me if I'm wrong, otherwise at least this should help the next guy looking for it.

    1kOhm current limiting resistors are connected to each pin

    LED R  - GPIO17
    LED G  - GPIO16
    LED B  - GPIO15
    

    Set GPIO to 0 to turn on and 1 to turn off. I'm guessing the invert is because most GPIO have better sinking capability than sourcing. I would have expect a slightly different resistor value, especially for Red as each color have different luminosity and to achieve a better "white" when all are turned on.

    Below is some code to get started

    #Setup export and GPIO direction
    echo 17 > /sys/class/gpio/gpiochip0/subsystem/export
    echo 16 > /sys/class/gpio/gpiochip0/subsystem/export
    echo 15 > /sys/class/gpio/gpiochip0/subsystem/export
    echo out > /sys/class/gpio/gpio17/direction
    echo out > /sys/class/gpio/gpio16/direction
    echo out > /sys/class/gpio/gpio15/direction
    
    #turn off RGB LED
    echo 1 > /sys/class/gpio/gpio17/value
    echo 1 > /sys/class/gpio/gpio16/value
    echo 1 > /sys/class/gpio/gpio15/value
    
    #turn on R
    echo 0 > /sys/class/gpio/gpio17/value
    #turn on G
    echo 0 > /sys/class/gpio/gpio16/value
    #turn on B
    echo 0 > /sys/class/gpio/gpio15/value
    

  • administrators

    Nice! That's some good detective work :)

    We've actually made a tool that can run software PWM to control the colour of the LED. Check out this help desk article.



  • Lol, I was searching for RGB LED, no wonder I didn't find anything here and at the help desk. That's what I've been thinking, you guys wouldn't have missed such a simple thing.



  • Very nice work! Thank you very much. I am so stupid not realising that you needed a 0 to turn it on. Doh! Cheers!



  • The code for expled used in the help desk article is here https://github.com/OnionIoT/fast-gpio/blob/master/scripts/expled.sh in case someone is looking.


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.