-
-
Save marcomonteiro/8b3ff6353b0ca51f8f11 to your computer and use it in GitHub Desktop.
BBB LED blinking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/marcomonteiro/embd" | |
) | |
func main() { | |
host, rev, err := embd.DetectHost() | |
if (err != nil) { | |
fmt.Println(err) | |
return; | |
} | |
fmt.Printf("%+v %+v\n", string(host), string(rev)) | |
fmt.Println("Blinking...") | |
embd.InitLED() | |
defer embd.CloseLED() | |
led, err := embd.NewLED(3) | |
if (err != nil) { | |
fmt.Println("Error creating LED") | |
fmt.Println(err) | |
} | |
for { | |
led.Toggle() | |
time.Sleep(1000 * time.Millisecond) | |
} | |
fmt.Println("Done, see ya later!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And I'm getting:
debian@beaglebone:~$ ./beagle
BeagleBone Black
Blinking...
Error creating LED
host: invalid host "BeagleBone Black"
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x14 pc=0x65490]
goroutine 1 [running]:
runtime.panic(0xd6668, 0x1c7f28)
/usr/local/Cellar/go/1.2.2/libexec/src/pkg/runtime/panic.c:266 +0x134
github.com/marcomonteiro/embd.CloseLED(0xb6f36740, 0x10500510)
/Users/marco/go/src/github.com/marcomonteiro/embd/led.go:54 +0x30
runtime.panic(0xd6668, 0x1c7f28)
/usr/local/Cellar/go/1.2.2/libexec/src/pkg/runtime/panic.c:248 +0xa4
main.main()
/Users/marco/go/src/github.com/user/beagle/beagle.go:29 +0x440
goroutine 3 [chan receive]:
github.com/golang/glog.(*loggingT).flushDaemon(0x1ca988)
/Users/marco/go/src/github.com/golang/glog/glog.go:839 +0x54
created by github.com/golang/glog.init·1
/Users/marco/go/src/github.com/golang/glog/glog.go:406 +0x2f8