You are here

Sample Source Code: BlinkStick Go Sample Code by Florian Sundermann Comments

This Go code sample can be used to control USB-LED devices such as BlinkStick, blink(1), LinkM / BlinkM, Blync, Busylight UC, Busylight Lync, DealExtreme USBMailNotifier, and DreamCheeky USBMailNotifier

Code sample:


package main

import (
    "fmt"
    "github.com/boombuler/led"
    "image/color"
    "time"
)

var RED color.RGBA = color.RGBA{0xFF, 0x00, 0x00, 0xFF}

func main() {
    for devInfo := range led.Devices() {
        dev, err := devInfo.Open()
        if err != nil {
            fmt.Println(err)
            continue
        }
        defer dev.Close()
        dev.SetColor(RED)

        time.Sleep(2 * time.Second) // Wait 2 seconds because the device will turn off once it is closed!
    }
}


BlinkStick is a smart LED controller with integrated USB firmware. It plugs into your computer and allows control the color of individually addressable or single color LEDs and LED strips and wide range programming language implementations give you the power to control the LEDs without the need to program a microcontroller.