MENGHIDUPKAN SEVEN SEGMEN DENGAN INPUT KEYPAD
1. Prosedur Kerja [back]
- Pastikan semua supply dalam keadaan off
- Hubungkan jumper seperti gambar dibawah
- Buatlah listing program yang telah ada pada modul.
- Hidupkan supply pada modul
- Upload program pada rangkaian
- Tekan tombol Reset
- Amati percobaan, jika tidak sesuai perbaiki rangkaian atau program
- Jika sesuai, maka selesai dan demokan pada instruktur atau asisten yang mengawas
- Matikan supply pada modul
2. Hardware [back]
Board Arduino
Seven Segment
Keypad
3. Video Praktikum [back]
4. Flowchart [back]
5. Rangkaian Simulasi [back]
6. Listing Program [back]
#include <Keypad.h> //library
char tombol[4][3] =
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte pinBaris[] = {28, 30, 32, 34};
byte pinKolom[] = {22, 24, 26};
Keypad keypad = Keypad(makeKeymap(tombol),
pinBaris, pinKolom, 4, 3);
void setup()
{
pinMode(2, OUTPUT);
pinMode(10, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
}
void loop()
{
char kode = keypad.getKey();
if (kode == NO_KEY)
return;
if (kode == '0')
{ digitalWrite(2, LOW);
digitalWrite(10, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
else if (kode == '1')
{ digitalWrite(2, HIGH);
digitalWrite(10, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
}
char tombol[4][3] =
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte pinBaris[] = {28, 30, 32, 34};
byte pinKolom[] = {22, 24, 26};
Keypad keypad = Keypad(makeKeymap(tombol),
pinBaris, pinKolom, 4, 3);
void setup()
{
pinMode(2, OUTPUT);
pinMode(10, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
}
void loop()
{
char kode = keypad.getKey();
if (kode == NO_KEY)
return;
if (kode == '0')
{ digitalWrite(2, LOW);
digitalWrite(10, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
else if (kode == '1')
{ digitalWrite(2, HIGH);
digitalWrite(10, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
}
Comments
Post a Comment