gobot.io/x/gobot@v1.16.0/examples/wifi_firmata_blink.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 /* 6 How to setup 7 You must be using a WiFi-connected microcontroller, 8 that has been flashed with the WifiFirmata sketch. 9 You then run the go program on your computer, and communicate 10 wirelessly with the microcontroller. 11 12 How to run 13 Pass the IP address/port as first param: 14 15 go run examples/wifi_firmata_blink.go 192.168.0.39:3030 16 */ 17 18 package main 19 20 import ( 21 "os" 22 "time" 23 24 "gobot.io/x/gobot" 25 "gobot.io/x/gobot/drivers/gpio" 26 "gobot.io/x/gobot/platforms/firmata" 27 ) 28 29 func main() { 30 firmataAdaptor := firmata.NewTCPAdaptor(os.Args[1]) 31 led := gpio.NewLedDriver(firmataAdaptor, "2") 32 33 work := func() { 34 gobot.Every(1*time.Second, func() { 35 led.Toggle() 36 }) 37 } 38 39 robot := gobot.NewRobot("bot", 40 []gobot.Connection{firmataAdaptor}, 41 []gobot.Device{led}, 42 work, 43 ) 44 45 robot.Start() 46 }