1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 21:00:05 +01:00
embd/samples/gpio.go

34 lines
444 B
Go
Raw Normal View History

2014-02-17 03:41:53 +05:30
package main
import (
"time"
"github.com/kidoman/embd"
2014-02-17 03:41:53 +05:30
)
func main() {
gpio, err := embd.NewGPIO()
2014-02-17 03:41:53 +05:30
if err != nil {
panic(err)
}
defer gpio.Close()
2014-02-17 03:41:53 +05:30
led, err := gpio.DigitalPin(10)
if err != nil {
2014-02-17 03:41:53 +05:30
panic(err)
}
if err := led.SetDir(embd.Out); err != nil {
2014-02-17 03:41:53 +05:30
panic(err)
}
if err := led.Write(embd.High); err != nil {
2014-02-17 03:41:53 +05:30
panic(err)
}
time.Sleep(1 * time.Second)
if err := led.SetDir(embd.In); err != nil {
2014-02-17 03:41:53 +05:30
panic(err)
}
}