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

     1  # GoPiGo3
     2  
     3  The GoPiGo3 is a robotics controller by Dexter Industries that is compatible with the Raspberry Pi.
     4  
     5  ## How to Install
     6  
     7  ```
     8  go get -d -u gobot.io/x/gobot/v2/...
     9  ```
    10  
    11  ## How to Use
    12  This example will blink the left and right leds red/blue.
    13  
    14  ```go
    15  package main
    16  
    17  import (
    18  	"fmt"
    19  	"time"
    20  
    21  	"gobot.io/x/gobot/v2"
    22  	g "gobot.io/x/gobot/v2/platforms/dexter/gopigo3"
    23  	"gobot.io/x/gobot/v2/platforms/raspi"
    24  )
    25  
    26  func main() {
    27  	raspiAdaptor := raspi.NewAdaptor()
    28  	gopigo3 := g.NewDriver(raspiAdaptor)
    29  
    30  	work := func() {
    31  		on := uint8(0xFF)
    32  		gobot.Every(1000*time.Millisecond, func() {
    33  			err := gopigo3.SetLED(g.LED_EYE_RIGHT, 0x00, 0x00, on)
    34  			if err != nil {
    35  				fmt.Println(err)
    36  			}
    37  			err = gopigo3.SetLED(g.LED_EYE_LEFT, ^on, 0x00, 0x00)
    38  			if err != nil {
    39  				fmt.Println(err)
    40  			}
    41  			on = ^on
    42  		})
    43  	}
    44  
    45  	robot := gobot.NewRobot("gopigo3",
    46  		[]gobot.Connection{raspiAdaptor},
    47  		[]gobot.Device{gopigo3},
    48  		work,
    49  	)
    50  
    51  	robot.Start()
    52  }
    53  ```