summaryrefslogtreecommitdiff
path: root/examples/keypad_example.cpp
blob: 781b8082917134ddf92c53d83e22389e5acb9c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
  }
}