#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#include "Adafruit_Keypad.h"
#define KEYPAD_PID3844
#define R1 2
#define R2 3
#define R3 4
#define R4 5
#define C1 6
#define C2 7
#define C3 10
#define C4 18
#include "keypad_config.h"
//initialize an instance of class NewKeypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
display.println("demo!!!!");
display.display();
customKeypad.begin();
}
void loop() {
// put your main code here, to run repeatedly:
customKeypad.tick();
while(customKeypad.available()){
display.clearDisplay();
display.setCursor(0, 0);
keypadEvent e = customKeypad.read();
display.print((char)e.bit.KEY);
if(e.bit.EVENT == KEY_JUST_PRESSED) display.println(" pressed");
else if(e.bit.EVENT == KEY_JUST_RELEASED) display.println(" released");
display.display();
}
delay(10);
}