mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-04 22:17:39 +08:00
examples: firmata examples take command line param for port to use to microcontroller
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
388e7adf59
commit
4c834e703c
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_blink.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_blinkm.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
blinkm := i2c.NewBlinkMDriver(firmataAdaptor)
|
blinkm := i2c.NewBlinkMDriver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,16 +2,25 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_button.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/drivers/gpio"
|
"gobot.io/x/gobot/drivers/gpio"
|
||||||
"gobot.io/x/gobot/platforms/firmata"
|
"gobot.io/x/gobot/platforms/firmata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
|
|
||||||
button := gpio.NewButtonDriver(firmataAdaptor, "2")
|
button := gpio.NewButtonDriver(firmataAdaptor, "2")
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_buzzer.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
buzzer := gpio.NewBuzzerDriver(firmataAdaptor, "3")
|
buzzer := gpio.NewBuzzerDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_cat_toy.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
servo1 := gpio.NewServoDriver(firmataAdaptor, "5")
|
servo1 := gpio.NewServoDriver(firmataAdaptor, "5")
|
||||||
servo2 := gpio.NewServoDriver(firmataAdaptor, "3")
|
servo2 := gpio.NewServoDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_curie_imu.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
imu := curie.NewIMUDriver(firmataAdaptor)
|
imu := curie.NewIMUDriver(firmataAdaptor)
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_curie_imu_shock_detect.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
imu := curie.NewIMUDriver(firmataAdaptor)
|
imu := curie.NewIMUDriver(firmataAdaptor)
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_curie_imu_step_counter.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
imu := curie.NewIMUDriver(firmataAdaptor)
|
imu := curie.NewIMUDriver(firmataAdaptor)
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_curie_imu_tap_detect.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
imu := curie.NewIMUDriver(firmataAdaptor)
|
imu := curie.NewIMUDriver(firmataAdaptor)
|
||||||
|
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_direct_pin.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
pin := gpio.NewDirectPinDriver(firmataAdaptor, "13")
|
pin := gpio.NewDirectPinDriver(firmataAdaptor, "13")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_hmc6352.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor)
|
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_integration.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led1 := gpio.NewLedDriver(firmataAdaptor, "3")
|
led1 := gpio.NewLedDriver(firmataAdaptor, "3")
|
||||||
led2 := gpio.NewLedDriver(firmataAdaptor, "4")
|
led2 := gpio.NewLedDriver(firmataAdaptor, "4")
|
||||||
button := gpio.NewButtonDriver(firmataAdaptor, "2")
|
button := gpio.NewButtonDriver(firmataAdaptor, "2")
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_led_brightness.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_led_brightness_with_analog_input.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/drivers/aio"
|
"gobot.io/x/gobot/drivers/aio"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
sensor := aio.NewAnalogSensorDriver(firmataAdaptor, "0")
|
sensor := aio.NewAnalogSensorDriver(firmataAdaptor, "0")
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
led := gpio.NewLedDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_lidarlite.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
lidar := i2c.NewLIDARLiteDriver(firmataAdaptor)
|
lidar := i2c.NewLIDARLiteDriver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,16 +2,25 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_makey_button.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/drivers/gpio"
|
"gobot.io/x/gobot/drivers/gpio"
|
||||||
"gobot.io/x/gobot/platforms/firmata"
|
"gobot.io/x/gobot/platforms/firmata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
button := gpio.NewMakeyButtonDriver(firmataAdaptor, "2")
|
button := gpio.NewMakeyButtonDriver(firmataAdaptor, "2")
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_mma7660.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
mma7660 := i2c.NewMMA7660Driver(firmataAdaptor)
|
mma7660 := i2c.NewMMA7660Driver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_motor.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
motor := gpio.NewMotorDriver(firmataAdaptor, "3")
|
motor := gpio.NewMotorDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_mpl115a2.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
mpl115a2 := i2c.NewMPL115A2Driver(firmataAdaptor)
|
mpl115a2 := i2c.NewMPL115A2Driver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_mpu6050.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
mpu6050 := i2c.NewMPU6050Driver(firmataAdaptor)
|
mpu6050 := i2c.NewMPU6050Driver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_pca9685.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -15,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
pca9685 := i2c.NewPCA9685Driver(firmataAdaptor)
|
pca9685 := i2c.NewPCA9685Driver(firmataAdaptor)
|
||||||
servo := gpio.NewServoDriver(pca9685, "15")
|
servo := gpio.NewServoDriver(pca9685, "15")
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_pir_motion.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/drivers/gpio"
|
"gobot.io/x/gobot/drivers/gpio"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
|
|
||||||
sensor := gpio.NewPIRMotionDriver(firmataAdaptor, "5")
|
sensor := gpio.NewPIRMotionDriver(firmataAdaptor, "5")
|
||||||
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_rgb_led.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
board := firmata.NewAdaptor("/dev/ttyACM0")
|
board := firmata.NewAdaptor(os.Args[1])
|
||||||
led := gpio.NewRgbLedDriver(board, "3", "5", "6")
|
led := gpio.NewRgbLedDriver(board, "3", "5", "6")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_servo.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
servo := gpio.NewServoDriver(firmataAdaptor, "3")
|
servo := gpio.NewServoDriver(firmataAdaptor, "3")
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
@ -2,9 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_temp36.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -14,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
gobot.Every(1*time.Second, func() {
|
gobot.Every(1*time.Second, func() {
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_travis.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -9,6 +16,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
@ -69,7 +77,7 @@ func checkTravis(robot *gobot.Robot) {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
master := gobot.NewMaster()
|
master := gobot.NewMaster()
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
red := gpio.NewLedDriver(firmataAdaptor, "7")
|
red := gpio.NewLedDriver(firmataAdaptor, "7")
|
||||||
red.SetName("red")
|
red.SetName("red")
|
||||||
green := gpio.NewLedDriver(firmataAdaptor, "6")
|
green := gpio.NewLedDriver(firmataAdaptor, "6")
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
//
|
//
|
||||||
// Do not build by default.
|
// Do not build by default.
|
||||||
|
|
||||||
|
/*
|
||||||
|
How to run
|
||||||
|
Pass serial port to use as the first param:
|
||||||
|
|
||||||
|
go run examples/firmata_wiichuck.go /dev/ttyACM0
|
||||||
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/drivers/i2c"
|
"gobot.io/x/gobot/drivers/i2c"
|
||||||
@ -13,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
firmataAdaptor := firmata.NewAdaptor(os.Args[1])
|
||||||
wiichuck := i2c.NewWiichuckDriver(firmataAdaptor)
|
wiichuck := i2c.NewWiichuckDriver(firmataAdaptor)
|
||||||
|
|
||||||
work := func() {
|
work := func() {
|
||||||
|
37
examples/wifi_firmata_analog_input.go
Normal file
37
examples/wifi_firmata_analog_input.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// +build example
|
||||||
|
//
|
||||||
|
// Do not build by default.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gobot.io/x/gobot"
|
||||||
|
"gobot.io/x/gobot/drivers/aio"
|
||||||
|
"gobot.io/x/gobot/platforms/firmata"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
firmataAdaptor := firmata.NewTCPAdaptor(os.Args[1])
|
||||||
|
sensor := aio.NewAnalogSensorDriver(firmataAdaptor, "A0")
|
||||||
|
|
||||||
|
work := func() {
|
||||||
|
sensor.On(aio.Data, func(data interface{}) {
|
||||||
|
brightness := uint8(
|
||||||
|
gobot.ToScale(gobot.FromScale(float64(data.(int)), 0, 1024), 0, 255),
|
||||||
|
)
|
||||||
|
fmt.Println("sensor", data)
|
||||||
|
fmt.Println("brightness", brightness)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
robot := gobot.NewRobot("sensorBot",
|
||||||
|
[]gobot.Connection{firmataAdaptor},
|
||||||
|
[]gobot.Device{sensor},
|
||||||
|
work,
|
||||||
|
)
|
||||||
|
|
||||||
|
robot.Start()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user