avr: implement Get() function on AVR, and leave stubs for NRF and dummy machines

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2018-09-13 11:39:38 +02:00
committed by Ayke van Laethem
parent ec50db729d
commit ab6757fe11
4 changed files with 49 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"machine"
"runtime"
)
// This example assumes that the button is connected to pin 8. Change the value
// below to use a different pin.
const buttonPin = 8
func main() {
led := machine.GPIO{machine.LED}
led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
button := machine.GPIO{buttonPin}
button.Configure(machine.GPIOConfig{Mode: machine.GPIO_INPUT})
for {
if button.Get() {
led.Low()
} else {
led.High()
}
runtime.Sleep(runtime.Millisecond * 10)
}
}