Created
April 9, 2014 20:26
-
-
Save caius/10310889 to your computer and use it in GitHub Desktop.
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 ( | |
"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