2013-12-31 03:26:34 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2014-01-03 11:13:25 +01:00
|
|
|
"github.com/kid0m4n/go-rpi/interface/keypad/matrix4x3"
|
2014-02-07 21:51:18 +01:00
|
|
|
"github.com/stianeikeland/go-rpio"
|
2013-12-31 03:26:34 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
rowPins := []int{4, 17, 27, 22}
|
|
|
|
colPins := []int{23, 24, 25}
|
|
|
|
|
2014-02-07 21:51:18 +01:00
|
|
|
rpio.Open()
|
|
|
|
defer rpio.Close()
|
|
|
|
|
2013-12-31 03:26:34 +01:00
|
|
|
keypad := matrix4x3.New(rowPins, colPins)
|
|
|
|
|
|
|
|
for {
|
|
|
|
if key, err := keypad.PressedKey(); err == nil {
|
|
|
|
fmt.Printf("Key Pressed = %v\n", key)
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}
|