Created
December 9, 2015 01:49
-
-
Save ledongthuc/c425e83b78e223e2a8e6 to your computer and use it in GitHub Desktop.
Blink the led with EMBD in Raspberry
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/kidoman/embd" | |
_ "github.com/kidoman/embd/host/all" | |
) | |
func main() { | |
embd.InitGPIO() | |
defer embd.CloseGPIO() | |
pin4, _ := embd.NewDigitalPin(4) | |
pin4.SetDirection(embd.Out) | |
currentStatus := embd.Low | |
for { | |
if currentStatus == embd.Low { | |
fmt.Println("Change from LOW to HIGH") | |
currentStatus = embd.High | |
pin4.Write(embd.High) | |
} else { | |
fmt.Println("Change from HIGH to LOW") | |
currentStatus = embd.Low | |
pin4.Write(embd.Low) | |
} | |
time.Sleep(1 * time.Second) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment