gobot.io/x/gobot/v2@v2.1.0/examples/firmata_grove_lcd.go (about) 1 //go:build example 2 // +build example 3 4 // 5 // Do not build by default. 6 7 package main 8 9 import ( 10 "os" 11 "time" 12 13 "gobot.io/x/gobot/v2" 14 "gobot.io/x/gobot/v2/drivers/i2c" 15 "gobot.io/x/gobot/v2/platforms/firmata" 16 ) 17 18 func main() { 19 board := firmata.NewAdaptor(os.Args[1]) 20 screen := i2c.NewGroveLcdDriver(board) 21 22 work := func() { 23 screen.Write("hello") 24 25 screen.SetRGB(255, 0, 0) 26 27 gobot.After(5*time.Second, func() { 28 screen.Clear() 29 screen.Home() 30 screen.SetRGB(0, 255, 0) 31 // set a custom character in the first position 32 screen.SetCustomChar(0, i2c.CustomLCDChars["smiley"]) 33 // add the custom character at the end of the string 34 screen.Write("goodbye\nhave a nice day " + string(byte(0))) 35 gobot.Every(500*time.Millisecond, func() { 36 screen.Scroll(false) 37 }) 38 }) 39 40 screen.Home() 41 time.Sleep(1 * time.Second) 42 screen.SetRGB(0, 0, 255) 43 } 44 45 robot := gobot.NewRobot("screenBot", 46 []gobot.Connection{board}, 47 []gobot.Device{screen}, 48 work, 49 ) 50 51 robot.Start() 52 }