Home Forums MOCHAbin Forum Hardware discussions Tricolor LEDs – how to?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #50395
    Anonymous
    Inactive

    Hi all,

    A-la documentation, our Mochabin has three three-color LEDs, all at the front to the right of the power LED. They are said to be I2C controlled.
    How do I operate it? I very much like to make use of these LEDs (my previous box – Espressobin of course – had a plethora of GPIO pins, and I connected my own LEDs and operated them happily; Mochabin does not seem to expose GPIO pins, so I’d be really happy to be able to control the installed LEDs.
    I tried some i2c stuff against it but with no success.
    Thanks for any insight!

    #50398
    Anonymous
    Inactive

    Anyone? Please?

    #50407
    Anonymous
    Inactive

    Pretty please?…

    #50437
    Anonymous
    Inactive

    The LEDs are hooked up using i2c to a driver chip – a is31fl319x which has a corresponding userspace driver leds_is31fl319x
    The is31fl319x is located on i2c bus 1 at 0x64, and on ArchLinux, the driver module leds_is31fl319x loads at boot. If you run i2cdetect -y 1 you see that 0x64 has the value UU, indicating that the driver is controlling that address. lsmod confirms this.

    If you want to control the LEDs you can write code to talk to the driver.

    Alternately you can remove the driver (rmmod leds_is31fl319x), which will allow access to 0x64, and you can use i2c (i2ctransfer) to send instructions to the is31fl319x directly.

    For example:

    i2ctransfer -y 1 w76@0x64 0x00 0x01 0x01 0x77 0x21 0x07 0x03 0x00 0x04 0x00 0x07 0xff 0x08 0xff 0x09 0xff 0x0a 0xff 0x0b 0xff 0x0c 0xff 0x0d 0xff 0x0e 0xff 0x0f 0xff 0x10 0x00 0x11 0x00 0x12 0x01 0x13 0x02 0x14 0x05 0x15 0x04 0x16 0x03 0x17 0x06 0x18 0x07 0x19 0x09 0x1a 0xa0 0x1b 0xa0 0x1c 0xa0 0x1d 0x07 0x1e 0x07 0x1f 0x07 0x20 0x07 0x21 0x07 0x22 0x07 0x23 0x07 0x24 0x07 0x25 0x07 0x26 0x00 0x03 0x70

    #50439
    Anonymous
    Inactive

    With more exploration… from userspace:

    echo 30 > /sys/class/leds/red:led1/brightness
    echo 30 > /sys/class/leds/green:led2/brightness
    echo 30 > /sys/class/leds/blue:led3/brightness

    etc.

    #50512
    dhliu
    Keymaster

    technosf was right,

    1. There are three tri-color LEDs as led1, led2 and led3 with red, green and blue color each
    You may find 9 sub-directories under /sys/class/leds, they are:

    Led1:red
    Led1:green
    Led1:blue
    Led2:red
    Led2:green
    Led2:blue
    Led3:red
    Led3:green
    Led3:blue

    Under the shell, give value 0 to 255 as brightness to the associated led
    For example:
    echo 100 > /sys/class/leds/led3\:red/brightness
    echo 100 > /sys/class/leds/led1\:blue/brightness

    The script below will display blue green cyna red magenta yellow white from LED1 to LED3 then turn off

    #!/bin/bash

    function rgbled {
    local idx=$1
    local color=$2
    local r=0
    local g=0
    local b=0

    case “$color” in
    black)
    r=0; g=0; b=0;
    ;;
    blue)
    r=0; g=0; b=255;
    ;;
    green)
    r=0; g=255; b=0;
    ;;
    cyna)
    r=0; g=255; b=255;
    ;;
    red)
    r=255; g=0; b=0;
    ;;
    magenta)
    r=255; g=0; b=255;
    ;;
    yellow)
    r=255; g=255; b=0;
    ;;
    white)
    r=255; g=255; b=255;
    ;;
    *)
    r=0; g=0; b=0;
    ;;
    esac

    echo $r > /sys/class/leds/led${idx}\:red/brightness
    echo $g > /sys/class/leds/led${idx}\:green/brightness
    echo $b > /sys/class/leds/led${idx}\:blue/brightness
    }

    # turn off all leds
    for led in {1..3};
    do
    rgbled $led
    done

    # leds demo
    for color in blue green cyna red magenta yellow white;
    do
    for led in {1..3};
    do
    rgbled $led $color
    sleep 0.3
    done

    sleep 1
    for led in {1..3};
    do
    rgbled $led
    done
    sleep 0.3
    done

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Signup to our newsletter

Technical specification tables can not be displayed on mobile. Please view on desktop