New Beaglebone Black I/O Library

Up to this point I’ve been testing hwio with Go on the Beaglebone black, which is ok, and seems to work.

Then a couple of days ago I got Go Newsletter #23, which somehow led me to a link to EMBD, an alternative that sounded similar, so I thought it would be worth a look; the examples sure seem simple!

Installation – because this is in Go – is a breeze. Just ‘go get’ the package from github and all is well. It also plays totally nice with my cross-compile environment from Dave Cheney’s post, so that’s nifty. With the BBB on wireless I simply do a ‘go-linux-arm build whatevs.go’ on my Mac, and then scp the binary ‘whatevs’ to /home/root/go on the BBB for testing. Nice.

First up, the normal blink test. Making a random guess that the LED names were ‘USR’ and not ‘LED’, it seemed to blink an LED just fine. This is the simpleblinker.go sample, with edits:

// +build ignore

// Simple LED blinker, works OOTB on a RPi. However, it does not clean up
// after itself. So might leave the LED On. The RPi is not harmed though.
 
// Edit: Changed host to 'bbb' from 'rpi' and "USR1" instead of "LED0" in the sample

package main

import (
  "time"

  "github.com/kidoman/embd"
  _ "github.com/kidoman/embd/host/bbb" // This loads the RPi bbb driver
)

func main() {
  for {
    embd.LEDToggle("USR1")
    time.Sleep(250 * time.Millisecond)
  }
}

Next up: World Domination!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.