1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-04 22:17:39 +08:00
hybridgroup.gobot/examples/wifi_firmata_blink.go
Thomas Kohler 865e724af0
Build(v2): revert move to v2 subfolder (#932)
* revert move to v2 subfolder
* fix CI and adjust CHANGELOG
2023-05-29 19:23:28 +02:00

49 lines
869 B
Go

//go:build example
// +build example
//
// Do not build by default.
/*
How to setup
You must be using a WiFi-connected microcontroller,
that has been flashed with the WifiFirmata sketch.
You then run the go program on your computer, and communicate
wirelessly with the microcontroller.
How to run
Pass the IP address/port as first param:
go run examples/wifi_firmata_blink.go 192.168.0.39:3030
*/
package main
import (
"os"
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
)
func main() {
firmataAdaptor := firmata.NewTCPAdaptor(os.Args[1])
led := gpio.NewLedDriver(firmataAdaptor, "2")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}