gobot.io/x/gobot@v1.16.0/examples/gopigo3.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "fmt" 9 "time" 10 11 "gobot.io/x/gobot" 12 "gobot.io/x/gobot/platforms/dexter/gopigo3" 13 "gobot.io/x/gobot/platforms/raspi" 14 ) 15 16 func main() { 17 raspiAdaptor := raspi.NewAdaptor() 18 gpg3 := gopigo3.NewDriver(raspiAdaptor) 19 20 work := func() { 21 on := uint8(0xFF) 22 gobot.Every(1000*time.Millisecond, func() { 23 err := gpg3.SetLED(gopigo3.LED_EYE_RIGHT, 0x00, 0x00, on) 24 if err != nil { 25 fmt.Println(err) 26 } 27 err = gpg3.SetLED(gopigo3.LED_EYE_LEFT, ^on, 0x00, 0x00) 28 if err != nil { 29 fmt.Println(err) 30 } 31 on = ^on 32 }) 33 } 34 35 robot := gobot.NewRobot("gopigo3eyeleds", 36 []gobot.Connection{raspiAdaptor}, 37 []gobot.Device{gpg3}, 38 work, 39 ) 40 41 robot.Start() 42 }