func main() { gbot := gobot.NewGobot() board := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0") led := gpio.NewRgbLedDriver(board, "led", "3", "5", "6") work := func() { gobot.Every(1*time.Second, func() { r := uint8(gobot.Rand(255)) g := uint8(gobot.Rand(255)) b := uint8(gobot.Rand(255)) led.SetRGB(r, g, b) }) } robot := gobot.NewRobot("rgbBot", []gobot.Connection{board}, []gobot.Device{led}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { beaglebone := new(gobotBeaglebone.Beaglebone) beaglebone.Name = "beaglebone" blinkm := gobotI2C.NewBlinkM(beaglebone) blinkm.Name = "blinkm" work := func() { gobot.Every("3s", func() { r := byte(gobot.Rand(255)) g := byte(gobot.Rand(255)) b := byte(gobot.Rand(255)) blinkm.Rgb(r, g, b) fmt.Println("color", blinkm.Color()) }) } robot := gobot.Robot{ Connections: []gobot.Connection{beaglebone}, Devices: []gobot.Device{blinkm}, Work: work, } robot.Start() }
func main() { gbot := gobot.NewGobot() e := joule.NewJouleAdaptor("joule") blinkm := i2c.NewBlinkMDriver(e, "blinkm") work := func() { gobot.Every(3*time.Second, func() { r := byte(gobot.Rand(255)) g := byte(gobot.Rand(255)) b := byte(gobot.Rand(255)) blinkm.Rgb(r, g, b) color, _ := blinkm.Color() fmt.Println("color", color) }) } robot := gobot.NewRobot("blinkmBot", []gobot.Connection{e}, []gobot.Device{blinkm}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() firmataAdaptor := firmata.NewFirmataAdaptor("firmata", "/dev/ttyACM0") blinkm := i2c.NewBlinkMDriver(firmataAdaptor, "blinkm") work := func() { gobot.Every(3*time.Second, func() { r := byte(gobot.Rand(255)) g := byte(gobot.Rand(255)) b := byte(gobot.Rand(255)) blinkm.Rgb(r, g, b) fmt.Println("color", blinkm.Color()) }) } robot := gobot.NewRobot("blinkmBot", []gobot.Connection{firmataAdaptor}, []gobot.Device{blinkm}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() beagleboneAdaptor := beaglebone.NewBeagleboneAdaptor("beaglebone") blinkm := i2c.NewBlinkMDriver(beagleboneAdaptor, "blinkm") work := func() { gobot.Every(3*time.Second, func() { r := byte(gobot.Rand(255)) g := byte(gobot.Rand(255)) b := byte(gobot.Rand(255)) blinkm.Rgb(r, g, b) fmt.Println("color", blinkm.Color()) }) } robot := gobot.NewRobot("blinkmBot", []gobot.Connection{beagleboneAdaptor}, []gobot.Device{blinkm}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() e := edison.NewEdisonAdaptor("edison") led := gpio.NewRgbLedDriver(e, "led", "3", "5", "6") work := func() { gobot.Every(1*time.Second, func() { r := uint8(gobot.Rand(255)) g := uint8(gobot.Rand(255)) b := uint8(gobot.Rand(255)) led.SetRGB(r, g, b) }) } robot := gobot.NewRobot("rgbBot", []gobot.Connection{e}, []gobot.Device{led}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1]) ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie") work := func() { gobot.Every(1*time.Second, func() { r := uint8(gobot.Rand(255)) g := uint8(gobot.Rand(255)) b := uint8(gobot.Rand(255)) ollie.SetRGB(r, g, b) }) } robot := gobot.NewRobot("ollieBot", []gobot.Connection{bleAdaptor}, []gobot.Device{ollie}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() adaptor := sphero.NewSpheroAdaptor("Sphero", "/dev/rfcomm0") spheroDriver := sphero.NewSpheroDriver(adaptor, "sphero") work := func() { gobot.On(spheroDriver.Event("collision"), func(data interface{}) { fmt.Println("Collision Detected!") }) gobot.Every(3*time.Second, func() { spheroDriver.Roll(30, uint16(gobot.Rand(360))) }) gobot.Every(1*time.Second, func() { r := uint8(gobot.Rand(255)) g := uint8(gobot.Rand(255)) b := uint8(gobot.Rand(255)) spheroDriver.SetRGB(r, g, b) }) } robot := gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{spheroDriver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/tty.Sphero-BRB-AMP-SPP") driver := sphero.NewSpheroDriver(adaptor, "sphero") work := func() { gobot.Every(100*time.Millisecond, func() { driver.SetRGB( uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255))) }) } robot := gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{driver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { deviceName := flag.String("device", "", "path to Sphero device") flag.Parse() gbot := gobot.NewGobot() adaptor := sphero.NewSpheroAdaptor("sphero", *deviceName) driver := sphero.NewSpheroDriver(adaptor, "sphero") 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, ) gbot.AddRobot(robot) gbot.Start() }
func main() { master := gobot.NewGobot() spheros := map[string]string{ "Sphero-BPO": "/dev/rfcomm0", } for name, port := range spheros { spheroAdaptor := sphero.NewSpheroAdaptor("sphero", port) spheroDriver := sphero.NewSpheroDriver(spheroAdaptor, "sphero") work := func() { spheroDriver.SetRGB(uint8(255), uint8(0), uint8(0)) } master.Robots = append(master.Robots, gobot.NewRobot(name, []gobot.Connection{spheroAdaptor}, []gobot.Device{spheroDriver}, work)) } master.Robots = append(master.Robots, gobot.NewRobot( "", nil, nil, func() { gobot.Every(1*time.Second, func() { gobot.Call(master.Robot("Sphero-BPO").Device("sphero").Driver, "SetRGB", uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255))) }) }, )) master.Start() }
func main() { gbot := gobot.NewGobot() spheros := []string{ "/dev/rfcomm0", "/dev/rfcomm1", "/dev/rfcomm2", "/dev/rfcomm3", } for _, port := range spheros { spheroAdaptor := sphero.NewSpheroAdaptor("Sphero", port) spheroDriver := sphero.NewSpheroDriver(spheroAdaptor, "Sphero"+port) work := func() { spheroDriver.Stop() spheroDriver.On(sphero.Collision, func(data interface{}) { fmt.Println("Collision Detected!") }) gobot.Every(1*time.Second, func() { spheroDriver.Roll(100, uint16(gobot.Rand(360))) }) gobot.Every(3*time.Second, func() { spheroDriver.SetRGB(uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), ) }) } robot := gobot.NewRobot("sphero", []gobot.Connection{spheroAdaptor}, []gobot.Device{spheroDriver}, work, ) gbot.AddRobot(robot) } gbot.Start() }
func main() { gbot := gobot.NewGobot() spheros := map[string]string{ "Sphero-BPO": "/dev/rfcomm0", } for name, port := range spheros { spheroAdaptor := sphero.NewSpheroAdaptor("sphero", port) spheroDriver := sphero.NewSpheroDriver(spheroAdaptor, "sphero") work := func() { spheroDriver.SetRGB(uint8(255), uint8(0), uint8(0)) } robot := gobot.NewRobot(name, []gobot.Connection{spheroAdaptor}, []gobot.Device{spheroDriver}, work, ) gbot.AddRobot(robot) } robot := gobot.NewRobot("", func() { gobot.Every(1*time.Second, func() { sphero := gbot.Robot("Sphero-BPO").Device("sphero").(*sphero.SpheroDriver) sphero.SetRGB(uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), ) }) }, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() adaptor := sphero.NewSpheroAdaptor("Sphero", "/dev/rfcomm0") spheroDriver := sphero.NewSpheroDriver(adaptor, "sphero") work := func() { spheroDriver.SetDataStreaming(sphero.DefaultDataStreamingConfig()) gobot.On(spheroDriver.Event(sphero.Collision), func(data interface{}) { fmt.Printf("Collision! %+v\n", data) }) gobot.On(spheroDriver.Event(sphero.SensorData), func(data interface{}) { fmt.Printf("Streaming Data! %+v\n", data) }) gobot.Every(3*time.Second, func() { spheroDriver.Roll(30, uint16(gobot.Rand(360))) }) gobot.Every(1*time.Second, func() { r := uint8(gobot.Rand(255)) g := uint8(gobot.Rand(255)) b := uint8(gobot.Rand(255)) spheroDriver.SetRGB(r, g, b) }) } robot := gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{spheroDriver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { master := gobot.NewGobot() spheros := []string{ "/dev/rfcomm0", "/dev/rfcomm1", "/dev/rfcomm2", "/dev/rfcomm3", } for s := range spheros { spheroAdaptor := sphero.NewSpheroAdaptor("Sphero", spheros[s]) spheroDriver := sphero.NewSpheroDriver(spheroAdaptor, "Sphero"+spheros[s]) work := func() { spheroDriver.Stop() gobot.On(spheroDriver.Events["Collision"], func(data interface{}) { fmt.Println("Collision Detected!") }) gobot.Every(1*time.Second, func() { spheroDriver.Roll(100, uint16(gobot.Rand(360))) }) gobot.Every(3*time.Second, func() { spheroDriver.SetRGB(uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255))) }) } master.Robots = append(master.Robots, gobot.NewRobot("sphero", []gobot.Connection{spheroAdaptor}, []gobot.Device{spheroDriver}, work)) } master.Start() }
func main() { gbot := gobot.NewGobot() beagleboneAdaptor := beaglebone.NewBeagleboneAdaptor("beaglebone") servo := gpio.NewServoDriver(beagleboneAdaptor, "servo", "P9_14") work := func() { gobot.Every(1*time.Second, func() { i := uint8(gobot.Rand(180)) fmt.Println("Turning", i) servo.Move(i) }) } gbot.Robots = append(gbot.Robots, gobot.NewRobot("servoBot", []gobot.Connection{beagleboneAdaptor}, []gobot.Device{servo}, work)) gbot.Start() }
func main() { gbot := gobot.NewGobot() firmataAdaptor := firmata.NewFirmataAdaptor("firmata", "/dev/ttyACM0") servo := gpio.NewServoDriver(firmataAdaptor, "servo", "3") work := func() { gobot.Every(1*time.Second, func() { i := uint8(gobot.Rand(180)) fmt.Println("Turning", i) servo.Move(i) }) } gbot.Robots = append(gbot.Robots, gobot.NewRobot("servoBot", []gobot.Connection{firmataAdaptor}, []gobot.Device{servo}, work)) gbot.Start() }
func main() { gbot := gobot.NewGobot() digisparkAdaptor := digispark.NewDigisparkAdaptor("digispark") servo := gpio.NewServoDriver(digisparkAdaptor, "servo", "0") work := func() { gobot.Every(1*time.Second, func() { i := uint8(gobot.Rand(180)) fmt.Println("Turning", i) servo.Move(i) }) } gbot.Robots = append(gbot.Robots, gobot.NewRobot("servoBot", []gobot.Connection{digisparkAdaptor}, []gobot.Device{servo}, work)) gbot.Start() }
func main() { master := gobot.GobotMaster() spheros := map[string]string{ "Sphero-BPO": "/dev/rfcomm0", } for name, port := range spheros { spheroAdaptor := new(gobotSphero.SpheroAdaptor) spheroAdaptor.Name = "sphero" spheroAdaptor.Port = port sphero := gobotSphero.NewSphero(spheroAdaptor) sphero.Name = "sphero" sphero.Interval = "0.5s" work := func() { sphero.SetRGB(uint8(255), uint8(0), uint8(0)) } master.Robots = append(master.Robots, &gobot.Robot{ Name: name, Connections: []gobot.Connection{spheroAdaptor}, Devices: []gobot.Device{sphero}, Work: work, }) } master.Robots = append(master.Robots, &gobot.Robot{ Work: func() { sphero := master.FindRobot("Sphero-BPO") gobot.Every("1s", func() { gobot.Call(sphero.GetDevice("sphero").Driver, "SetRGB", uint8(gobot.Rand(255)), uint8(gobot.Rand(255)), uint8(gobot.Rand(255))) }) }, }) master.Start() }
func main() { gbot := gobot.NewGobot() adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/tty.Sphero-BRB-AMP-SPP") driver := sphero.NewSpheroDriver(adaptor, "sphero") work := func() { gobot.Every(1*time.Second, func() { driver.Roll(50, uint16(gobot.Rand(360))) }) } robot := gobot.NewRobot("sphero", []gobot.Connection{adaptor}, []gobot.Device{driver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1]) ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie") work := func() { ollie.SetRGB(255, 0, 255) gobot.Every(3*time.Second, func() { ollie.Roll(40, uint16(gobot.Rand(360))) }) } robot := gobot.NewRobot("ollieBot", []gobot.Connection{bleAdaptor}, []gobot.Device{ollie}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { spheroAdaptor := new(gobotSphero.SpheroAdaptor) spheroAdaptor.Name = "Sphero" spheroAdaptor.Port = "/dev/rfcomm0" sphero := gobotSphero.NewSphero(spheroAdaptor) sphero.Name = "Sphero" work := func() { gobot.Every("2s", func() { sphero.Roll(100, uint16(gobot.Rand(360))) }) } robot := gobot.Robot{ Connections: []gobot.Connection{spheroAdaptor}, Devices: []gobot.Device{sphero}, Work: work, } robot.Start() }
func main() { beaglebone := new(gobotBeaglebone.Beaglebone) beaglebone.Name = "beaglebone" servo := gobotGPIO.NewServo(beaglebone) servo.Name = "servo" servo.Pin = "P9_14" work := func() { gobot.Every("1s", func() { i := uint8(gobot.Rand(180)) fmt.Println("Turning", i) servo.Move(i) }) } robot := gobot.Robot{ Connections: []gobot.Connection{beaglebone}, Devices: []gobot.Device{servo}, Work: work, } robot.Start() }
func (c *conway) movement() { if c.alive { c.cell.Roll(100, uint16(gobot.Rand(360))) } }
func ExampleRand() { i := gobot.Rand(100) fmt.Sprintln("%v is > 0 && < 100", i) }
func ExampleRand() { i := gobot.Rand(100) fmt.Printf("%v is > 0 && < 100", i) }