1. Kondisi[kembali]
Bila ditekan angka 2 pada keypad maka akan muncul sevensegment counter down 9-0
2. Gambar Rangkaian Simulasi[kembali]
#include <Keypad.h>
char tombol[4][3] =
{
{'1', '2', '3'},
{'4', '5', '6'}, //inisiasi untuk keypad matriks 4x3
{'7', '8', '9'},
{'*', '0', '#'}
};
byte pinBaris[] = {17, 18, 19, 20}; //inisiasi pin keypad di arduino
byte pinKolom[] = {14, 15, 16}; //inisiasi pin keypad di arduino
Keypad keypad = Keypad(makeKeymap(tombol),
pinBaris, pinKolom, 4, 3); //inisiasi keypad dari library
void setup() {
pinMode(7, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> a
pinMode(8, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> b
pinMode(9, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> c
pinMode(10, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> d
pinMode(11, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> e
pinMode(12, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> f
pinMode(13, OUTPUT); //inisiasi pin 10 sebagai OUTPUT di arduino ==> g
}
void loop() {
char kode = keypad.getKey(); //membaca keypad
if (kode == NO_KEY) //jika tombol tidak di tekan
return;
if (kode == '0') //kondisi awal jika tombol 0 ditekan
{ digitalWrite(7, HIGH); //pin 2 menuju a bernilai 1
digitalWrite(8, HIGH); //pin 3 menuju b bernilai 1
digitalWrite(9, HIGH); //pin 4 menuju c bernilai 1
digitalWrite(10, HIGH); //pin 5 menuju d bernilai 1
digitalWrite(11, HIGH); //pin 6 menuju e bernilai 1
digitalWrite(12, HIGH); //pin 7 menuju f bernilai 1
digitalWrite(13, LOW); //pin 8 menuju g bernilai 0
}
else if(kode == '2') //kondisi awal jika tombol 2 ditekan
{ digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,LOW);
delay(1000);
}
}
5. Video Simulasi[kembali]
6. Prinsip Kerja Rangkaian[kembali]
Prinsip kerja rangkaian diatas adalah kontrol dari arduino untuk memproses data input dari keypad lalu diolah dan outputnya ditampilkan pada seven segment. Ketika angka 2 pada keypad ditekan maka data akan masuk pada arduino, pada program arduino angka 2 dikenali sebagai counter down angka dari 9 sampai angka 0, lalu arduino mengeksekusi program tersebut dengan menampilkannya pada seven segment
7. Link Download[kembali]
Tidak ada komentar:
Posting Komentar