#include <Keypad.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <RotaryEncoder.h>
#define RotA 7
#define RotB 8
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const uint8_t ROWS = 3; //four rows
const uint8_t COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'1','2','3','4'},
{'5','6','7','8'},
{'9','0','A','B'}
};
uint8_t rowPins[ROWS] = {9, 10, 6}; //connect to the row pinouts of the keypad
uint8_t colPins[COLS] = {0, 1, 2, 3}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial1.begin(115200);
Serial1.println("Hello, Raspberry Pi Pico W!");
input_password.reserve(32);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial1.println(F("SSD1306 allocation failed"));
for(;;);
}
}
void loop(){
char button = keypad.getKey();
if (button){
displayMessage(button);
}
}
void displayMessage(String message) {
display.clearDisplay();
display.setCursor(0, 0);
display.println(message);
display.display();
}