#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Servo.h>
Servo myservo;
int potpin = 2;
int val;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
const uint8_t ROWS = 4;
const uint8_t COLS = 4;
char keys[ROWS][COLS] =
{
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
uint8_t colPins[COLS] = { 3, 2, A0, A1 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 7, 6, 5, 4 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
myservo.attach(A3);
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
lcd.setCursor(0,0);
lcd.clear();
Serial.println(key);
}
lcd.print(key);
delay(100);
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
delay(15);
}