This commit is contained in:
Daniel Ledda
2020-10-31 13:18:26 +01:00
parent 57bdc21041
commit 415bcc8593

View File

@@ -17,7 +17,8 @@ func main() {
panic(err)
}
defer gpio.Close()
pin := gpio.NewPin(gpio.GPIO7)
pinNumber := gpio.GPIO7
pin := gpio.NewPin(pinNumber)
pin.Input()
pin.PullUp()
@@ -27,7 +28,7 @@ func main() {
defer signal.Stop(quit)
err = pin.Watch(gpio.EdgeBoth, func(pin *gpio.Pin) {
fmt.Printf("Pin 4 is %v", pin.Read())
fmt.Printf("Pin %v is %v", pinNumber, pin.Read())
})
if err != nil {
panic(err)
@@ -36,7 +37,7 @@ func main() {
// In a real application the main thread would do something useful here.
// But we'll just run for a minute then exit.
fmt.Println("Watching Pin 4...")
fmt.Printf("Watching Pin %v...", pinNumber)
select {
case <-time.After(time.Minute):
case <-quit: