2014-03-02 08:06:34 +01:00
|
|
|
// +build ignore
|
|
|
|
|
2014-02-26 23:54:53 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-04-04 22:13:16 +02:00
|
|
|
"flag"
|
2014-02-26 23:54:53 +01:00
|
|
|
"time"
|
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
"github.com/kidoman/embd"
|
2014-04-06 03:20:09 +02:00
|
|
|
|
|
|
|
_ "github.com/kidoman/embd/host/all"
|
2014-02-26 23:54:53 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-04 22:13:16 +02:00
|
|
|
flag.Parse()
|
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
h, _, err := embd.DetectHost()
|
2014-02-26 23:54:53 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var pinNo interface{}
|
|
|
|
|
|
|
|
switch h {
|
2014-03-02 20:21:23 +01:00
|
|
|
case embd.HostBBB:
|
2014-02-26 23:54:53 +01:00
|
|
|
pinNo = "P9_31"
|
2014-03-02 20:21:23 +01:00
|
|
|
case embd.HostRPi:
|
2014-02-26 23:54:53 +01:00
|
|
|
pinNo = 10
|
|
|
|
default:
|
|
|
|
panic("host not supported (yet :P)")
|
|
|
|
}
|
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
if err := embd.InitGPIO(); err != nil {
|
2014-02-26 23:54:53 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
2014-03-02 20:21:23 +01:00
|
|
|
defer embd.CloseGPIO()
|
2014-02-26 23:54:53 +01:00
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
led, err := embd.NewDigitalPin(pinNo)
|
2014-02-26 23:54:53 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer led.Close()
|
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
if err := led.SetDirection(embd.Out); err != nil {
|
2014-02-26 23:54:53 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
2014-03-02 20:21:23 +01:00
|
|
|
if err := led.Write(embd.High); err != nil {
|
2014-02-26 23:54:53 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
|
2014-03-02 20:21:23 +01:00
|
|
|
if err := led.SetDirection(embd.In); err != nil {
|
2014-02-26 23:54:53 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|