Go's package for Arduino
Goduino uses Firmata protocol for Arduino
- Download and install the Arduio IDE
- Plug in your Arduino via USB
- Open the Arduino IDE and open:
File > Examples > StandardFirmata
- Select Arduino´s board:
Tools > Board
- Select Arduino´s serial port:
Tools > Serial Port
- Click the Upload button
go get github.com/argandas/goduino
package main
import (
"fmt"
"github.com/argandas/goduino"
"time"
)
func main() {
arduino := goduino.New("myArduino", "COM1")
err := arduino.Connect()
if err != nil {
fmt.Println(err)
return
}
defer arduino.Disconnect()
arduino.PinMode(13, goduino.Output)
for {
arduino.DigitalWrite(13, 1)
arduino.Delay(time.Millisecond * 500)
arduino.DigitalWrite(13, 0)
arduino.Delay(time.Millisecond * 500)
}
}
Note: For this example the selected serial port is COM1
, be sure your Arduino is connected on this serial port.
This package has been tested on Go v1.4.2 & Firmata v2.4