update
This commit is contained in:
7
main.go
7
main.go
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user