本文整理汇总了Golang中gobot/io/x/gobot/drivers/gpio.NewLedDriver函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLedDriver函数的具体用法?Golang NewLedDriver怎么用?Golang NewLedDriver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLedDriver函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:26,代码来源:firmata_travis.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:35,代码来源:joule_leds.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:33,代码来源:firmata_integration.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:25,代码来源:particle_led_brightness.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:25,代码来源:raspi_button.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:28,代码来源:edison_button_led_api.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:25,代码来源:digispark_led_brightness.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:29,代码来源:mqtt_firmata_blink.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:25,代码来源:firmata_pir_motion.go
示例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)
}
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:16,代码来源:firmata_blink_metal.go
示例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)
}
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:16,代码来源:edison_blink_without_all_gobot_framework.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:16,代码来源:digispark_api.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:firmata_blink_robot.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:chip_blink.go
示例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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:digispark_blink.go
示例16: main
func main() {
e := joule.NewAdaptor()
led := gpio.NewLedDriver(e, "100")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)
robot.Start()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:joule_blink.go
示例17: main
func main() {
r := raspi.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot.Start()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:raspi_blink.go
示例18: main
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()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:wifi_firmata_blink.go
示例19: main
func main() {
core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
[]gobot.Device{led},
work,
)
robot.Start()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:particle_blink.go
示例20: main
func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P9_12")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:beaglebone_blink.go
注:本文中的gobot/io/x/gobot/drivers/gpio.NewLedDriver函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论