#include "Keypad_I2C.h"
#include "Grove_LCD_RGB_Backlight.h"
rgb_lcd lcd;
const int colorR = 100;
const int colorG = 100;
const int colorB = 100;
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char* I2CTYPE = "Adafruit_MCP23017";
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {6, 5, 4, 3}; //row pins
byte colPins[COLS] = {2, 1, 0}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CTYPE );
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Set up background backlight color
lcd.setRGB(colorR, colorG, colorB);
lcd.print("hello, world!");
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
lcd.setCursor(0,1);
lcd.print(key);
}
}
Comments
Please log in or sign up to comment.