Skip to content

Instantly share code, notes, and snippets.

@caius
Created April 9, 2014 20:26
Show Gist options
  • Save caius/10310889 to your computer and use it in GitHub Desktop.
Save caius/10310889 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/stianeikeland/go-rpio"
"time"
)
var green rpio.Pin
var red rpio.Pin
var blue rpio.Pin
func main() {
err := rpio.Open()
if err != nil {
panic(err)
}
green := rpio.Pin(17)
green.Output()
red := rpio.Pin(18)
red.Output()
blue := rpio.Pin(27)
blue.Output()
red.Low()
green.Low()
blue.Low()
display := make(chan rpio.Pin)
go func(in chan rpio.Pin) {
var previousPin rpio.Pin
for newPin := range in {
if previousPin != 0 {
previousPin.Low()
}
previousPin = newPin
newPin.High()
}
}(display)
for {
display <- blue
time.Sleep(500 * time.Millisecond)
display <- red
time.Sleep(500 * time.Millisecond)
display <- green
time.Sleep(500 * time.Millisecond)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment