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