1
0
mirror of https://github.com/kidoman/embd synced 2024-06-13 22:29:53 +02:00
embd/samples/keypad/matrix4x3.go

38 lines
579 B
Go
Raw Normal View History

2014-03-02 08:06:34 +01:00
// +build ignore
2013-12-31 03:26:34 +01:00
package main
import (
"fmt"
"time"
"github.com/cfreeman/embd"
"github.com/cfreeman/embd/interface/keypad/matrix4x3"
2013-12-31 03:26:34 +01:00
)
func main() {
rowPins := []int{4, 17, 27, 22}
colPins := []int{23, 24, 25}
2014-03-02 20:25:20 +01:00
if err := embd.InitGPIO(); err != nil {
2014-03-02 07:39:57 +01:00
panic(err)
}
2014-03-02 20:25:20 +01:00
defer embd.CloseGPIO()
2014-03-02 07:39:57 +01:00
keypad, err := matrix4x3.New(rowPins, colPins)
if err != nil {
panic(err)
}
2013-12-31 03:26:34 +01:00
for {
2014-03-02 07:39:57 +01:00
key, err := keypad.PressedKey()
if err != nil {
panic(err)
}
if key != matrix4x3.KNone {
2013-12-31 03:26:34 +01:00
fmt.Printf("Key Pressed = %v\n", key)
}
time.Sleep(500 * time.Millisecond)
}
}