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.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
39 changed files
with
1,660 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/i2c" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("edison") | ||
accel := i2c.NewGroveAccelerometerDriver(board, "accel") | ||
|
||
work := func() { | ||
gobot.Every(500*time.Millisecond, func() { | ||
if x, y, z, err := accel.XYZ(); err == nil { | ||
fmt.Println(x, y, z) | ||
fmt.Println(accel.Acceleration(x, y, z)) | ||
} else { | ||
fmt.Println(err) | ||
} | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("accelBot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{accel}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
e := edison.NewEdisonAdaptor("edison") | ||
led := gpio.NewLedDriver(e, "led", "13") | ||
|
||
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() | ||
} |
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,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
e := edison.NewEdisonAdaptor("edison") | ||
button := gpio.NewGroveButtonDriver(e, "button", "2") | ||
|
||
work := func() { | ||
gobot.On(button.Event(gpio.Push), func(data interface{}) { | ||
fmt.Println("On!") | ||
}) | ||
|
||
gobot.On(button.Event(gpio.Release), func(data interface{}) { | ||
fmt.Println("Off!") | ||
}) | ||
|
||
} | ||
|
||
robot := gobot.NewRobot("bot", | ||
[]gobot.Connection{e}, | ||
[]gobot.Device{button}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,55 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("edison") | ||
buzzer := gpio.NewBuzzerDriver(board, "buzzer", "3") | ||
|
||
work := func() { | ||
type note struct { | ||
tone float64 | ||
duration float64 | ||
} | ||
|
||
song := []note{ | ||
{gpio.C4, gpio.Quarter}, | ||
{gpio.C4, gpio.Quarter}, | ||
{gpio.G4, gpio.Quarter}, | ||
{gpio.G4, gpio.Quarter}, | ||
{gpio.A4, gpio.Quarter}, | ||
{gpio.A4, gpio.Quarter}, | ||
{gpio.G4, gpio.Half}, | ||
{gpio.F4, gpio.Quarter}, | ||
{gpio.F4, gpio.Quarter}, | ||
{gpio.E4, gpio.Quarter}, | ||
{gpio.E4, gpio.Quarter}, | ||
{gpio.D4, gpio.Quarter}, | ||
{gpio.D4, gpio.Quarter}, | ||
{gpio.C4, gpio.Half}, | ||
} | ||
|
||
for _, val := range song { | ||
buzzer.Tone(val.tone, val.duration) | ||
<-time.After(10 * time.Millisecond) | ||
} | ||
} | ||
|
||
robot := gobot.NewRobot("bot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{buzzer}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,43 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/i2c" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("edison") | ||
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) | ||
screen.Write("goodbye") | ||
}) | ||
|
||
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() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
e := edison.NewEdisonAdaptor("edison") | ||
led := gpio.NewGroveLedDriver(e, "led", "4") | ||
|
||
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() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("board") | ||
sensor := gpio.NewGroveLightSensorDriver(board, "sensor", "0") | ||
|
||
work := func() { | ||
gobot.On(sensor.Event("data"), func(data interface{}) { | ||
fmt.Println("sensor", data) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("sensorBot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{sensor}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("edison") | ||
sensor := gpio.NewGrovePiezoVibrationSensorDriver(board, "sensor", "0") | ||
|
||
work := func() { | ||
gobot.On(sensor.Event(gpio.Vibration), func(data interface{}) { | ||
fmt.Println("got one!") | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("bot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{sensor}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("board") | ||
sensor := gpio.NewGroveRotaryDriver(board, "sensor", "0") | ||
|
||
work := func() { | ||
gobot.On(sensor.Event("data"), func(data interface{}) { | ||
fmt.Println("sensor", data) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("sensorBot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{sensor}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
"github.com/hybridgroup/gobot/platforms/intel-iot/edison" | ||
) | ||
|
||
func main() { | ||
gbot := gobot.NewGobot() | ||
|
||
board := edison.NewEdisonAdaptor("board") | ||
sensor := gpio.NewGroveSoundSensorDriver(board, "sensor", "0") | ||
|
||
work := func() { | ||
gobot.On(sensor.Event("data"), func(data interface{}) { | ||
fmt.Println("sensor", data) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("sensorBot", | ||
[]gobot.Connection{board}, | ||
[]gobot.Device{sensor}, | ||
work, | ||
) | ||
|
||
gbot.AddRobot(robot) | ||
|
||
gbot.Start() | ||
} |
Oops, something went wrong.