summaryrefslogtreecommitdiff
path: root/examples/keypad_example.cpp
diff options
context:
space:
mode:
authorHombreLaser <buran@silosneeded.com>2024-06-09 17:44:39 -0600
committerHombreLaser <buran@silosneeded.com>2024-06-09 17:44:39 -0600
commit765c8e55f206637ee0a5948f34f0ebfe9acd7d86 (patch)
tree88712bd4db68a09348f95f6fd29bdaef13a0c7f9 /examples/keypad_example.cpp
parentd9300dbeac7178f7d74e851d3d9c0b4c990faac6 (diff)
Add examplesHEADmaster
Diffstat (limited to 'examples/keypad_example.cpp')
-rw-r--r--examples/keypad_example.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/keypad_example.cpp b/examples/keypad_example.cpp
new file mode 100644
index 0000000..781b808
--- /dev/null
+++ b/examples/keypad_example.cpp
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include "pico/types.h"
+#include "pico/time.h"
+#include "pico/stdio.h"
+#include "keypad.hpp"
+
+int main() {
+ uint col_pins[4] = {6, 7, 8, 9};
+ uint row_pins[4] = {16, 17, 18, 19};
+ char keypad_chars[4][4] = {
+ {'1', '2', '3', 'A'},
+ {'4', '5', '6', 'B'},
+ {'7', '8', '9', 'C'},
+ {'*', '0', '#', 'D'}
+ };
+ Keypad keypad(row_pins, col_pins, keypad_chars);
+
+ stdio_init_all();
+
+ while(true) {
+ char key = keypad.getKey();
+ if(key != '\0')
+ printf("%c\n", key);
+
+ busy_wait_ms(150);
+ }
+}