0% found this document useful (0 votes)
22 views

Source Code Arduino Keypad Dan LCD

The document describes using a keypad and LCD to display inputted numbers and characters. It also describes creating an animated screensaver on the LCD by scrolling and moving characters and symbols.

Uploaded by

Reinaldo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Source Code Arduino Keypad Dan LCD

The document describes using a keypad and LCD to display inputted numbers and characters. It also describes creating an animated screensaver on the LCD by scrolling and moving characters and symbols.

Uploaded by

Reinaldo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

Keypad + LCD
a. Script Isi Program

#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 7, 8, 9, 10);

char keys[rows][cols] = { //@SIM char[][] keys = new char[][]{


{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[] = { 0, 1, 2, 3 };
byte colPins[] = { 6, 5, 4 };
Keypad keypad = Keypad(rowPins, colPins, sizeOf(rowPins) ,
sizeOf(colPins) );
#define ledPin 13
int count = 0;
char X='a';
int i = 0;

void setup()
{
digitalWrite(ledPin, HIGH);
Serial.begin(9600);
lcd.begin(16, 2);
keypad.addEventListener(keypadEvent);
}

void loop()
{
lcd.setCursor(0,0);
lcd.print("Tekan Tombol");
lcd.setCursor(i, 1);
keypad.getKey();
char key = keypad.getKey();
if (key != NO_KEY && key!='#')
{
if(X != key)
{
lcd.print(key);
X = key;
i++;
if (i == 17)
{
lcd.clear();
i = 0;
}
}
}
}

void keypadEvent(KeypadEvent eKey) {


switch (eKey) {
case '*':
digitalWrite(ledPin, HIGH);
break;
case '#':
digitalWrite(ledPin, LOW);
X = 'a';
break;
case KEY_RELEASED:
Serial.println("Key Released");
break;
default:
if (eKey != NO_KEY){
Serial.println(eKey);
}
}
}
b. Screenshot
- Sebelum Keypad ditekan

- Saat Tombol ‘1’ ditekan

- Saat Tombol ‘2’ ditekan


- Saat Tombol ‘3’ ditekan

- Saat Tombol ‘4’ ditekan

- Saat Tombol ‘5’ ditekan


- Saat Tombol ‘6’ ditekan

- Saat Tombol ‘7’ ditekan

- Saat Tombol ‘8’ ditekan


- Saat Tombol ‘9’ ditekan

- Saat Tombol ‘*’ ditekan

- Saat Tombol ‘0’ ditekan


- Saat Tombol ‘#’ ditekan

(Catatan = Tombol ‘#’


tidak muncul pada LCD
ketika ditekan karena
diprogram demikian,
dimana tombol ‘#’
berguna agar LCD dapat
menampilkan karakter
pada keypad ketika
tombol karakter yang
ditekan merupakan
tombol yang sama dengan
yang ditekan sebelumnya,
misal = ‘11’ maka pada
keypad ditekan ‘1’ , ‘#‘ ,
‘1’ )
2. Screensaver
a. Script Isi Program

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 2, 3, 4, 5) ;
void setup() {
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("L");
lcd.setCursor(0, 1);
lcd.print(">");
delay(500);
lcd.setCursor(1, 0);
lcd.print("O");
lcd.setCursor(1, 1);
lcd.print(">");
delay(500);
lcd.setCursor(2, 0);
lcd.print("A");
lcd.setCursor(2, 1);
lcd.print(">");
delay(500);
lcd.setCursor(3, 0);
lcd.print("D");
lcd.setCursor(3, 1);
lcd.print(">");
delay(500);
lcd.setCursor(4, 0);
lcd.print("I");
lcd.setCursor(4, 1);
lcd.print(">");
delay(500);
lcd.setCursor(5, 0);
lcd.print("N");
lcd.setCursor(5, 1);
lcd.print(">");
delay(500);
lcd.setCursor(6, 0);
lcd.print("G");
lcd.setCursor(6, 1);
lcd.print(">");
delay(500);
lcd.setCursor(7, 0);
lcd.print(".");
lcd.setCursor(7, 1);
lcd.print(">");
delay(500);
lcd.setCursor(8, 0);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(">");
delay(500);
lcd.setCursor(9, 0);
lcd.print(".");
lcd.setCursor(9, 1);
lcd.print(">");
delay(500);
lcd.setCursor(10, 0);
lcd.print(" ");
lcd.setCursor(10, 1);
lcd.print(">");
delay(500);
lcd.setCursor(11, 0);
lcd.print(".");
lcd.setCursor(11, 1);
lcd.print(">");
delay(500);
lcd.setCursor(12, 0);
lcd.print(" ");
lcd.setCursor(12, 1);
lcd.print(">");
delay(500);
lcd.setCursor(13, 0);
lcd.print(".");
lcd.setCursor(13, 1);
lcd.print(">");
delay(500);
lcd.setCursor(14, 0);
lcd.print(" ");
lcd.setCursor(14, 1);
lcd.print(">");
delay(500);
lcd.setCursor(15, 0);
lcd.print(".");
lcd.setCursor(15, 1);
lcd.print(">");
delay(500);
lcd.clear();

for(int i=0;i <= 15;i++){


lcd.setCursor(i, 0);
lcd.print("( '_' )");
delay(500);
lcd.clear();
}

for(int i=15;i >= 0;i--){


lcd.setCursor(i, 1);
lcd.print("( '_' )");
delay(500);
lcd.clear();
}

for(int i=0;i <= 10;i++){


lcd.setCursor(i, 0);
lcd.print("(^o^)/");
lcd.setCursor(15 - i, 1);
lcd.print("`(^O^)/");
delay(500);
lcd.clear();
}

for(int i=0;i <= 15;i++){


lcd.setCursor(i, 0);
lcd.print("o(^V^)o");
lcd.setCursor(i, 1);
lcd.print("o(^V^)o");
delay(500);
lcd.clear();
}
for(int i=15;i >= 0;i--){
lcd.setCursor(i, 0);
lcd.print("`(*^o^*)");
lcd.setCursor(i, 1);
lcd.print("(*^o^*)'");
delay(500);
lcd.clear();
}

lcd.setCursor(0, 1);
lcd.print("(^_^)// \\\\(^-^)");
delay(2500);
lcd.clear();

lcd.setCursor(0, 1);
lcd.print("`(^U^)//(T_T)");
delay(2500);
lcd.clear();

for(int i=3;i <= 15;i++){


lcd.setCursor(i, 0);
lcd.print("`('o ' )/ ");
lcd.setCursor(15 - i, 1);
lcd.print("`(T^T)/");
delay(500);
lcd.clear();
}

for(int i=0;i <= 15;i++){


lcd.setCursor(i, 0);
lcd.print(">");
lcd.setCursor(15 - i, 1);
lcd.print("<");
delay(500);
}
lcd.clear();

}
b. Screenshot
- Tampilan pada detik ke 1

- Tampilan pada detik ke 5

- Tampilan pada detik ke 10

- Tampilan pada detik ke 15


- Tampilan pada detik ke 20

- Tampilan pada detik ke 25

- Tampilan pada detik ke 30

- Tampilan pada detik ke 35


- Tampilan pada detik ke 40

- Tampilan pada detik ke 45

- Tampilan pada detik ke 50

- Tampilan pada detik ke 55


- Tampilan pada detik ke 60

- Tampilan pada detik ke 65

You might also like