コード例 #1
0
ファイル: joule_blinkm.go プロジェクト: ympons/gobot
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()
}
コード例 #2
0
ファイル: joule_rgb_led.go プロジェクト: ympons/gobot
func main() {
	gbot := gobot.NewGobot()

	e := joule.NewJouleAdaptor("joule")
	led := gpio.NewRgbLedDriver(e, "led", "25", "27", "29")

	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()
}
コード例 #3
0
ファイル: joule_grove_lcd.go プロジェクト: ympons/gobot
func main() {
	gbot := gobot.NewGobot()

	board := joule.NewJouleAdaptor("joule")
	screen := i2c.NewGroveLcdDriver(board, "screen")

	work := func() {
		screen.Write("hello")

		screen.SetRGB(255, 0, 0)

		gobot.After(5*time.Second, func() {
			screen.Clear()
			screen.Home()
			screen.SetRGB(0, 255, 0)
			// set a custom character in the first position
			screen.SetCustomChar(0, i2c.CustomLCDChars["smiley"])
			// add the custom character at the end of the string
			screen.Write("goodbye\nhave a nice day " + string(byte(0)))
			gobot.Every(500*time.Millisecond, func() {
				screen.Scroll(false)
			})
		})

		screen.Home()
		<-time.After(1 * time.Second)
		screen.SetRGB(0, 0, 255)
	}

	robot := gobot.NewRobot("screenBot",
		[]gobot.Connection{board},
		[]gobot.Device{screen},
		work,
	)

	gbot.AddRobot(robot)

	gbot.Start()
}
コード例 #4
0
ファイル: joule_blink.go プロジェクト: ympons/gobot
func main() {
	gbot := gobot.NewGobot()

	e := joule.NewJouleAdaptor("joule")
	led := gpio.NewLedDriver(e, "led", "100")

	work := func() {
		gobot.Every(1*time.Second, func() {
			led.Toggle()
		})
	}

	robot := gobot.NewRobot("blinkBot",
		[]gobot.Connection{e},
		[]gobot.Device{led},
		work,
	)

	gbot.AddRobot(robot)

	gbot.Start()
}
コード例 #5
0
ファイル: joule_leds.go プロジェクト: ympons/gobot
func main() {
	gbot := gobot.NewGobot()

	e := joule.NewJouleAdaptor("joule")
	led0 := gpio.NewLedDriver(e, "led", "100")
	led1 := gpio.NewLedDriver(e, "led", "101")
	led2 := gpio.NewLedDriver(e, "led", "102")
	led3 := gpio.NewLedDriver(e, "led", "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(2*time.Second, func() {
			led2.Toggle()
		})
		gobot.Every(3*time.Second, func() {
			led3.Toggle()
		})
	}

	robot := gobot.NewRobot("blinkBot",
		[]gobot.Connection{e},
		[]gobot.Device{led0, led1, led2, led3},
		work,
	)

	gbot.AddRobot(robot)

	gbot.Start()
}