tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/blinkm/main.go (about) 1 // Connects to an BlinkM I2C RGB LED. 2 // http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf 3 package main 4 5 import ( 6 "machine" 7 "time" 8 9 "tinygo.org/x/drivers/blinkm" 10 ) 11 12 func main() { 13 machine.I2C0.Configure(machine.I2CConfig{}) 14 15 bm := blinkm.New(machine.I2C0) 16 bm.Configure() 17 18 maj, min, _ := bm.Version() 19 20 println("Firmware version:", string(maj), string(min)) 21 22 count := 0 23 for { 24 switch count { 25 case 0: 26 // Crimson 27 bm.SetRGB(0xdc, 0x14, 0x3c) 28 count = 1 29 case 1: 30 // MediumPurple 31 bm.SetRGB(0x93, 0x70, 0xdb) 32 count = 2 33 case 2: 34 // MediumSeaGreen 35 bm.SetRGB(0x3c, 0xb3, 0x71) 36 count = 0 37 } 38 39 time.Sleep(100 * time.Millisecond) 40 } 41 }