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