gobot.io/x/gobot/v2@v2.1.0/platforms/particle/README.md (about)

     1  # Particle
     2  
     3  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.
     4  
     5  For more info about the Particle platform go to https://www.particle.io/
     6  
     7  ## How to Install
     8  
     9  Installing Gobot with Particle support is pretty easy.
    10  
    11  ```
    12  go get -d -u gobot.io/x/gobot/v2/...
    13  ```
    14  
    15  ## How to Use
    16  
    17  ```go
    18  package main
    19  
    20  import (
    21  	"time"
    22  
    23  	"gobot.io/x/gobot/v2"
    24  	"gobot.io/x/gobot/v2/drivers/gpio"
    25  	"gobot.io/x/gobot/v2/platforms/particle"
    26  )
    27  
    28  func main() {
    29  	core := particle.NewAdaptor("device_id", "access_token")
    30  	led := gpio.NewLedDriver(core, "D7")
    31  
    32  	work := func() {
    33  		gobot.Every(1*time.Second, func() {
    34  			led.Toggle()
    35  		})
    36  	}
    37  
    38  	robot := gobot.NewRobot("spark",
    39  		[]gobot.Connection{core},
    40  		[]gobot.Device{led},
    41  		work,
    42  	)
    43  
    44  	robot.Start()
    45  }
    46  ```