Last active
March 28, 2022 13:37
-
-
Save gatarelib/5e379cd518fd7ac73e69964b8194d144 to your computer and use it in GitHub Desktop.
Golang framework for robotics, drones, and the Internet of Things (IoT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
"gobot.io/x/gobot" | |
"gobot.io/x/gobot/drivers/gpio" | |
"gobot.io/x/gobot/platforms/firmata" | |
) | |
func main() { | |
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0") | |
led := gpio.NewLedDriver(firmataAdaptor, "13") | |
work := func() { | |
gobot.Every(1*time.Second, func() { | |
led.Toggle() | |
}) | |
} | |
robot := gobot.NewRobot("bot", | |
[]gobot.Connection{firmataAdaptor}, | |
[]gobot.Device{led}, | |
work, | |
) | |
robot.Start() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build example | |
// | |
// Do not build by default. | |
package main | |
import ( | |
"time" | |
"gobot.io/x/gobot" | |
"gobot.io/x/gobot/platforms/audio" | |
) | |
func main() { | |
e := audio.NewAdaptor() | |
laser := audio.NewDriver(e, "./examples/laser.mp3") | |
work := func() { | |
gobot.Every(2*time.Second, func() { | |
laser.Play() | |
}) | |
} | |
robot := gobot.NewRobot("soundBot", | |
[]gobot.Connection{e}, | |
[]gobot.Device{laser}, | |
work, | |
) | |
robot.Start() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"gobot.io/x/gobot" | |
"gobot.io/x/gobot/platforms/sphero" | |
) | |
func main() { | |
adaptor := sphero.NewAdaptor("/dev/rfcomm0") | |
driver := sphero.NewSpheroDriver(adaptor) | |
work := func() { | |
gobot.Every(3*time.Second, func() { | |
driver.Roll(30, uint16(gobot.Rand(360))) | |
}) | |
} | |
robot := gobot.NewRobot("sphero", | |
[]gobot.Connection{adaptor}, | |
[]gobot.Device{driver}, | |
work, | |
) | |
robot.Start() | |
} |
You can use the entire Gobot framework as shown in the examples above, or you can pick and choose from the various Gobot packages to control hardware with nothing but pure idiomatic Golang code.
the audio.go
being an impementation example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the entire Gobot framework as shown in the examples above, or you can pick and choose from the various Gobot packages to control hardware with nothing but pure idiomatic Golang code.