tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/keypad4x4/main.go (about) 1 package main 2 3 import ( 4 "machine" 5 6 "tinygo.org/x/drivers/keypad4x4" 7 ) 8 9 func main() { 10 mapping := map[uint8]string{ 11 1: "1", 12 2: "2", 13 3: "3", 14 4: "A", 15 5: "4", 16 6: "5", 17 7: "6", 18 8: "B", 19 9: "7", 20 10: "8", 21 11: "9", 22 12: "C", 23 13: "*", 24 14: "0", 25 15: "#", 26 16: "D", 27 } 28 29 keypadDevice := keypad4x4.NewDevice(machine.D2, machine.D3, machine.D4, machine.D5, machine.D6, machine.D7, machine.D8, machine.D9) 30 keypadDevice.Configure() 31 32 for { 33 key := keypadDevice.GetKey() 34 if key != keypad4x4.NoKeyPressed { 35 println("Button: ", mapping[key]) 36 } 37 } 38 }