hybridgroup.gobot/platforms/particle/README.md

47 lines
1.3 KiB
Markdown
Raw Normal View History

# Particle
The Particle Photon and Particle Electron are connected microcontrollers from Particle (http://particle.io), the company formerly known as Spark Devices. The Photon uses a Wi-Fi connection to the Particle cloud, and the Electron uses a 3G wireless connection. Once the Photon or Electron connects to the network, it automatically connects with a central server (the "Particle Cloud") and stays connected so it can be controlled from external systems, such as a Gobot program. To run Gobot programs please make sure you are running default Tinker firmware on the Photon or Electron.
2014-11-29 07:34:42 +08:00
For more info about the Particle platform go to https://www.particle.io/
2014-11-29 07:34:42 +08:00
## How to Install
Installing Gobot with Particle support is pretty easy.
2014-06-10 10:01:53 +08:00
```
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/particle
2014-06-10 10:01:53 +08:00
```
2014-11-29 07:34:42 +08:00
## How to Use
```go
package main
import (
2014-07-11 08:02:00 +08:00
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/drivers/gpio"
"github.com/hybridgroup/gobot/platforms/particle"
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
led := gpio.NewLedDriver(core, "D7")
2014-07-11 08:02:00 +08:00
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
2014-07-11 08:02:00 +08:00
[]gobot.Device{led},
work,
)
robot.Start()
}
2014-07-11 08:02:00 +08:00
```