本文整理汇总了Golang中gobot/io/x/gobot/drivers/gpio.NewLedDriver函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLedDriver函数的具体用法?Golang NewLedDriver怎么用?Golang NewLedDriver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLedDriver函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
master := gobot.NewMaster()
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
red := gpio.NewLedDriver(firmataAdaptor, "7")
red.SetName("red")
green := gpio.NewLedDriver(firmataAdaptor, "6")
green.SetName("green")
blue := gpio.NewLedDriver(firmataAdaptor, "5")
blue.SetName("blue")
work := func() {
checkTravis(master.Robot("travis"))
gobot.Every(10*time.Second, func() {
checkTravis(master.Robot("travis"))
})
}
robot := gobot.NewRobot("travis",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{red, green, blue},
work,
)
master.AddRobot(robot)
master.Start()
}
示例2: main
func main() {
e := joule.NewAdaptor()
led0 := gpio.NewLedDriver(e, "100")
led1 := gpio.NewLedDriver(e, "101")
led2 := gpio.NewLedDriver(e, "102")
led3 := gpio.NewLedDriver(e, "103")
work := func() {
led0.Off()
led1.Off()
led2.Off()
led3.Off()
gobot.Every(1*time.Second, func() {
led0.Toggle()
})
gobot.Every(2*time.Second, func() {
led1.Toggle()
})
gobot.Every(4*time.Second, func() {
led2.Toggle()
})
gobot.Every(8*time.Second, func() {
led3.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led0, led1, led2, led3},
work,
)
robot.Start()
}
示例3: main
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led1 := gpio.NewLedDriver(firmataAdaptor, "3")
led2 := gpio.NewLedDriver(firmataAdaptor, "4")
button := gpio.NewButtonDriver(firmataAdaptor, "2")
sensor := gpio.NewAnalogSensorDriver(firmataAdaptor, "0")
work := func() {
gobot.Every(1*time.Second, func() {
led1.Toggle()
})
gobot.Every(2*time.Second, func() {
led2.Toggle()
})
button.On(gpio.ButtonPush, func(data interface{}) {
led2.On()
})
button.On(gpio.ButtonRelease, func(data interface{}) {
led2.Off()
})
sensor.On(gpio.Data, func(data interface{}) {
fmt.Println("sensor", data)
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led1, led2, button, sensor},
work,
)
robot.Start()
}
示例4: main
func main() {
core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "A1")
work := func() {
brightness := uint8(0)
fadeAmount := uint8(25)
gobot.Every(500*time.Millisecond, func() {
led.Brightness(brightness)
brightness = brightness + fadeAmount
if brightness == 0 || brightness == 255 {
fadeAmount = -fadeAmount
}
})
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
[]gobot.Device{led},
work,
)
robot.Start()
}
示例5: main
func main() {
r := raspi.NewAdaptor()
button := gpio.NewButtonDriver(r, "11")
led := gpio.NewLedDriver(r, "7")
work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
fmt.Println("button pressed")
led.On()
})
button.On(gpio.ButtonRelease, func(data interface{}) {
fmt.Println("button released")
led.Off()
})
}
robot := gobot.NewRobot("buttonBot",
[]gobot.Connection{r},
[]gobot.Device{button, led},
work,
)
robot.Start()
}
示例6: main
func main() {
master := gobot.NewMaster()
api.NewAPI(master).Start()
e := edison.NewAdaptor()
button := gpio.NewButtonDriver(e, "2")
led := gpio.NewLedDriver(e, "4")
work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
led.On()
})
button.On(gpio.ButtonRelease, func(data interface{}) {
led.Off()
})
}
robot := gobot.NewRobot("buttonBot",
[]gobot.Connection{e},
[]gobot.Device{led, button},
work,
)
master.AddRobot(robot)
master.Start()
}
示例7: main
func main() {
digisparkAdaptor := digispark.NewAdaptor()
led := gpio.NewLedDriver(digisparkAdaptor, "0")
work := func() {
brightness := uint8(0)
fadeAmount := uint8(15)
gobot.Every(100*time.Millisecond, func() {
led.Brightness(brightness)
brightness = brightness + fadeAmount
if brightness == 0 || brightness == 255 {
fadeAmount = -fadeAmount
}
})
}
robot := gobot.NewRobot("pwmBot",
[]gobot.Connection{digisparkAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}
示例8: main
func main() {
mqttAdaptor := mqtt.NewAdaptor("tcp://test.mosquitto.org:1883", "blinker")
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
work := func() {
mqttAdaptor.On("lights/on", func(data []byte) {
led.On()
})
mqttAdaptor.On("lights/off", func(data []byte) {
led.Off()
})
data := []byte("")
gobot.Every(1*time.Second, func() {
mqttAdaptor.Publish("lights/on", data)
})
gobot.Every(2*time.Second, func() {
mqttAdaptor.Publish("lights/off", data)
})
}
robot := gobot.NewRobot("mqttBot",
[]gobot.Connection{mqttAdaptor, firmataAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}
示例9: main
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
sensor := gpio.NewPIRMotionDriver(firmataAdaptor, "5")
led := gpio.NewLedDriver(firmataAdaptor, "13")
work := func() {
sensor.On(gpio.MotionDetected, func(data interface{}) {
fmt.Println(gpio.MotionDetected)
led.On()
})
sensor.On(gpio.MotionStopped, func(data interface{}) {
fmt.Println(gpio.MotionStopped)
led.Off()
})
}
robot := gobot.NewRobot("motionBot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{sensor, led},
work,
)
robot.Start()
}
示例10: main
// Example of a simple led toggle without the initialization of
// the entire gobot framework.
// This might be useful if you want to use gobot as another
// golang library to interact with sensors and other devices.
func main() {
f := firmata.NewAdaptor("/dev/ttyACM0")
f.Connect()
led := gpio.NewLedDriver(f, "13")
led.Start()
for {
led.Toggle()
time.Sleep(1000 * time.Millisecond)
}
}
示例11: main
// Example of a simple led toggle without the initialization of
// the entire gobot framework.
// This might be useful if you want to use gobot as another
// golang library to interact with sensors and other devices.
func main() {
e := edison.NewAdaptor()
e.Connect()
led := gpio.NewLedDriver(e, "13")
led.Start()
for {
led.Toggle()
time.Sleep(1000 * time.Millisecond)
}
}
示例12: main
func main() {
master := gobot.NewMaster()
api.NewAPI(master).Start()
digisparkAdaptor := digispark.NewAdaptor()
led := gpio.NewLedDriver(digisparkAdaptor, "0")
robot := gobot.NewRobot("digispark",
[]gobot.Connection{digisparkAdaptor},
[]gobot.Device{led},
)
master.AddRobot(robot)
master.Start()
}
示例13: main
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()
}
示例14: main
func main() {
chipAdaptor := chip.NewAdaptor()
led := gpio.NewLedDriver(chipAdaptor, "XIO-P6")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{chipAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}
示例15: main
func main() {
digisparkAdaptor := digispark.NewAdaptor()
led := gpio.NewLedDriver(digisparkAdaptor, "0")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{digisparkAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}