1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/examples/beaglebone_servo.go

36 lines
579 B
Go
Raw Normal View History

// +build example
//
// Do not build by default.
package main
import (
"fmt"
2014-07-10 17:21:21 -07:00
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/beaglebone"
)
func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
servo := gpio.NewServoDriver(beagleboneAdaptor, "P9_14")
work := func() {
2014-05-22 19:32:09 -07:00
gobot.Every(1*time.Second, func() {
i := uint8(gobot.Rand(180))
fmt.Println("Turning", i)
servo.Move(i)
})
}
2014-07-08 18:36:14 -07:00
robot := gobot.NewRobot("servoBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{servo},
work,
)
robot.Start()
}