gobot.io/x/gobot/v2@v2.1.0/examples/gopigo3.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 "fmt" 11 "time" 12 13 "gobot.io/x/gobot/v2" 14 "gobot.io/x/gobot/v2/platforms/dexter/gopigo3" 15 "gobot.io/x/gobot/v2/platforms/raspi" 16 ) 17 18 func main() { 19 raspiAdaptor := raspi.NewAdaptor() 20 gpg3 := gopigo3.NewDriver(raspiAdaptor) 21 22 work := func() { 23 on := uint8(0xFF) 24 gobot.Every(1000*time.Millisecond, func() { 25 err := gpg3.SetLED(gopigo3.LED_EYE_RIGHT, 0x00, 0x00, on) 26 if err != nil { 27 fmt.Println(err) 28 } 29 err = gpg3.SetLED(gopigo3.LED_EYE_LEFT, ^on, 0x00, 0x00) 30 if err != nil { 31 fmt.Println(err) 32 } 33 on = ^on 34 }) 35 } 36 37 robot := gobot.NewRobot("gopigo3eyeleds", 38 []gobot.Connection{raspiAdaptor}, 39 []gobot.Device{gpg3}, 40 work, 41 ) 42 43 robot.Start() 44 }