forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i2c: GrovePi digitalwrite implemented
Signed-off-by: Ron Evans <[email protected]>
- Loading branch information
1 parent
425fea3
commit c9276f4
Showing
3 changed files
with
108 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/gpio" | ||
"gobot.io/x/gobot/drivers/i2c" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
r := raspi.NewAdaptor() | ||
gp := i2c.NewGrovePiDriver(r) | ||
led := gpio.NewLedDriver(gp, "2") | ||
|
||
work := func() { | ||
gobot.Every(1*time.Second, func() { | ||
led.Toggle() | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("blinkBot", | ||
[]gobot.Connection{r}, | ||
[]gobot.Device{gp, led}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |