mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
Added package for 4x3 keypad interface
This commit is contained in:
parent
1746e906fe
commit
66e1af44d8
2 changed files with 244 additions and 0 deletions
23
samples/keypad/matrix4x3.go
Normal file
23
samples/keypad/matrix4x3.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kid0m4n/go-rpi/sensor/keypad/matrix4x3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rowPins := []int{4, 17, 27, 22}
|
||||
colPins := []int{23, 24, 25}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue