Getting Started with Arduino and Go by Agus Kurniawan
Author:Agus Kurniawan [Kurniawan, Agus]
Language: eng
Format: epub
Publisher: PE Press
Published: 2015-03-02T05:00:00+00:00
$ go run main.go
On console, you can see the output as below.
Then, you can see LED is blinking on the Arduino board.
3.3 go-firmata
The second Firmata package for Go is go-firmata. You can read it on https://github.com/kraman/go-firmata . You can install this package by typing this command.
$ go get github.com/kraman/go-firmata
For illustration, we build a simple app, blinking led. We use LED on the board, LED on pin 13.
Now we create project called firmataclient by creating a folder, firmataclient.
$ mkdir firmataclient
$ cd firmataclient
Create a file, called main.go. Write the following code.
package main
import (
"fmt"
"time"
"github.com/kraman/go-firmata"
)
func main() {
board, err := firmata.NewClient("COM6", 57600) if err!=nil {
panic(err)
}
defer board.Close()
fmt.Println("SetPinMode")
board.SetPinMode(13,firmata.Output)
go func() {
fmt.Println("go run")
for {
fmt.Println("LED ON")
board.DigitalWrite(13, true)
time.Sleep(1 * time.Second)
fmt.Println("LED OFF")
board.DigitalWrite(13, false)
time.Sleep(1 * time.Second)
}
}()
// press ENTER to exit
fmt.Println("press Enter to exit..")
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3574)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3512)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3340)
TinyML Cookbook by Gian Marco Iodice(3286)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2837)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2208)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1948)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1946)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1897)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1857)
MicroPython Projects by Jacob Beningo(1728)
Hands-On Internet of Things with MQTT by Tim Pulver(1702)
