// Column 1 (left)
// C1 = Pin A0
// C2 = Pin A1
// C3 = Pin A2
// C4 = Pin 2
// Column 4 (right)
// Row 1 (top row)
// R1 = Pin 3
// R2 = Pin 4
// R3 = Pin 5
// R4 = Pin 6
// Row 4 (bottom row)
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
long Time = 0;
void setup()
{
lcd.begin(16, 2);
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop()
{
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(3, LOW);
if (digitalRead(A0) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('1');
Time = millis();
}
}
if (digitalRead(A1) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('2');
Time = millis();
}
}
if (digitalRead(A2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('3');
Time = millis();
}
}
if (digitalRead(2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('A');
Time = millis();
}
}
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(4, LOW);
if (digitalRead(A0) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('4');
Time = millis();
}
}
if (digitalRead(A1) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('5');
Time = millis();
}
}
if (digitalRead(A2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('6');
Time = millis();
}
}
if (digitalRead(2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('B');
Time = millis();
}
}
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
if (digitalRead(A0) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('7');
Time = millis();
}
}
if (digitalRead(A1) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('8');
Time = millis();
}
}
if (digitalRead(A2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('9');
Time = millis();
}
}
if (digitalRead(2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('C');
Time = millis();
}
}
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(6, LOW);
if (digitalRead(A0) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('*');
Time = millis();
}
}
if (digitalRead(A1) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('0');
Time = millis();
}
}
if (digitalRead(A2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('#');
Time = millis();
}
}
if (digitalRead(2) == 0)
{
if (millis() - Time > 500 )
{
lcd.print('D');
Time = millis();
}
}
}