Home

Awesome

go-firmata

A Golang wrapper for Firmata on Arduino

GoDoc

Installation

	go get github.com/kraman/go-firmata

Usage

package main

import (
	"github.com/kraman/go-firmata"
	"time"
)

var led uint8 = 13

func main() {
	arduino, err := firmata.NewClient("COM1", 57600)
	if err != nil {
		panic(err)
	}

	// arduino.Verbose = true

	myDelay := time.Millisecond * 250

	// Set led pin as output
	arduino.SetPinMode(led, firmata.Output)

	// Blink led 10 times
	for x := 0; x < 10; x++ {
		
		// Turn ON led
		arduino.DigitalWrite(led, true)
		arduino.Delay(myDelay)
		
		// Turn OFF led
		arduino.DigitalWrite(led, false)
		arduino.Delay(myDelay)

	}
	arduino.Close()
}