2016-10-01 18:28:28 +02:00
# Particle
2014-04-26 03:11:51 -07:00
2016-10-01 18:28:28 +02:00
The Particle Photon is a Wi-Fi connected microcontroller from Particle (http://particle.io), the company formerly known as Spark Devices. Once it connects to a Wi-Fi 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.
2014-11-28 15:34:42 -08:00
2016-10-01 18:28:28 +02:00
For more info about the Particle platform go to https://www.particle.io/
2014-11-28 15:34:42 -08:00
## How to Install
2016-10-01 18:28:28 +02:00
Installing Gobot with Particle support is pretty easy.
2014-04-26 03:11:51 -07:00
2014-06-09 19:01:53 -07:00
```
2016-10-01 18:28:28 +02:00
go get -d -u github.com/hybridgroup/gobot/... & & go install github.com/hybridgroup/gobot/platforms/particle
2014-06-09 19:01:53 -07:00
```
2014-04-26 03:11:51 -07:00
2014-11-28 15:34:42 -08:00
## How to Use
2014-04-26 03:11:51 -07:00
```go
package main
import (
2014-07-10 17:02:00 -07:00
"time"
"github.com/hybridgroup/gobot"
2016-10-01 18:28:28 +02:00
"github.com/hybridgroup/gobot/drivers/gpio"
"github.com/hybridgroup/gobot/platforms/particle"
2014-04-26 03:11:51 -07:00
)
func main() {
2016-10-01 18:28:28 +02:00
core := particle.NewAdaptor("device_id", "access_token")
led := gpio.NewLedDriver(core, "D7")
2014-04-26 03:11:51 -07:00
2014-07-10 17:02:00 -07:00
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
2014-04-26 03:11:51 -07:00
2014-07-10 17:02:00 -07:00
robot := gobot.NewRobot("spark",
[]gobot.Connection{sparkCore},
[]gobot.Device{led},
work,
)
2014-04-26 03:11:51 -07:00
2016-10-18 21:37:10 +02:00
robot.Start()
2014-04-26 03:11:51 -07:00
}
2014-07-10 17:02:00 -07:00
```