Percobaan 6
8x Switch SPDT DAN LCD
1. Foto Hardware dan Diagram Blok [Kembali]
a. Hardware
b. Diagram Blok
2. PROSEDUR PERCOBAAN [Kembali]
- Rangkai semua komponen
- Buat program di aplikasi arduino IDE
- Setelah selesai masukkan program ke arduino
- Jalankan program pada simulasi dan cobakan dengan modul
3. RANGKAIAN SIMULASI DAN PRINSIP KERJA[Kembali]
Pada percobaan 6 ini menggunakan button sebagai input yang terhubung ke Arduino dan Output dari percobaan ini adalah LCD. tombol yang digunakan dihubungkan ke pin Arduino, dan tampilan LCD ditentukan berdasarkan kombinasi status tombol yang ditekan. contohnya jika tombol PB1 ditekan (HIGH) dan tombol-tombol lainnya tidak(LOW), maka tampilan LCD akan menampilkan teks "Merah". Proses pembacaan status tombol dilakukan dalam loop utama, di mana setiap tombol direpresentasikan oleh variabel yang kemudian digunakan dalam serangkaian kondisi untuk menentukan tampilan LCD yang sesuai. Program ini memberikan tampilan yang berbeda tergantung pada kombinasi tombol yang ditekan.
4. FLOWCHART DAN LISTING PROGRAM [Kembali]
#include <LiquidCrystal.h>#define PB1 A0#define PB2 A1#define PB3 A2#define PB4 A3#define PB5 A4#define PB6 A5#define PB7 12#define PB8 13const int rs = 11, en = 10, d4 = 6, d5 = 5, d6 = 4, d7 = 3;LiquidCrystal lcd(rs, en, d4, d5, d6, d7);bool Button1, Button2, Button3, Button4, Button5, Button6, Button7, Button8;void setup() {Serial.begin(9600);lcd.begin(16, 2);pinMode(PB1, INPUT);pinMode(PB2, INPUT);pinMode(PB3, INPUT);pinMode(PB4, INPUT);pinMode(PB5, INPUT);pinMode(PB6, INPUT);pinMode(PB7, INPUT);pinMode(PB8, INPUT);}void loop() {Button1 = digitalRead(PB1);Button2 = digitalRead(PB2);Button3 = digitalRead(PB3);Button4 = digitalRead(PB4);Button5 = digitalRead(PB5);Button6 = digitalRead(PB6);Button7 = digitalRead(PB7);Button8 = digitalRead(PB8);if (Button1 == HIGH && Button2 == LOW && Button3 == LOW && Button4 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 0);lcd.print("Merah");} else if (Button2 == HIGH && Button1 == LOW && Button3 == LOW && Button4 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 0);lcd.print("Kuning");} else if (Button3 == HIGH && Button2 == LOW && Button1 == LOW && Button4 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 0);lcd.print("Hijau");} else if (Button4 == HIGH && Button2 == LOW && Button3 == LOW && Button1 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 0);lcd.print("Biru");} else if (Button5 == HIGH && Button2 == LOW && Button3 == LOW && Button4 == LOW && Button1 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 1);lcd.print("Merah");} else if (Button6 == HIGH && Button2 == LOW && Button3 == LOW && Button4 == LOW && Button5 == LOW &&Button1 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 1);lcd.print("Hijau");} else if (Button7 == HIGH && Button2 == LOW && Button3 == LOW && Button4 == LOW && Button5 == LOW &&Button6 == LOW && Button1 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 1);lcd.print("Biru");} else if (Button8 == HIGH && Button2 == LOW && Button3 == LOW && Button4 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button1 == LOW) {lcd.clear();lcd.setCursor(0, 1);lcd.print("Putih");} else if (Button1 == LOW && Button2 == LOW && Button3 == LOW && Button5 == LOW && Button5 == LOW &&Button6 == LOW && Button7 == LOW && Button8 == LOW) {lcd.clear();lcd.setCursor(0, 0);lcd.print("Silahkan Tekan");lcd.setCursor(0, 1);lcd.print("Salah Satu SW");} else {lcd.clear();lcd.setCursor(0, 0);lcd.print("Error");}delay(100); // Tambahkan penundaan agar tampilan tidak berubah terlalu cepat}
5. KONDISI [Kembali]
Ketika button di tekan maka LCD akan hidup menampilan karakter sesuai dengan button mana yang di tekan. tampilan output dari dual seven segmen tersebut diatur di kodingan arduino.
6. VIDEO RANGKAIAN [Kembali]
7. ANALISA [Kembali]
8. LINK DOWNLOAD [Kembali]
HTML klik disini
Rangkaian klik disini
Listing Program klik disini
Video Percobaan klik disini
Datasheet Arduino klik disini
Datasheet SPDT klik disini
Tidak ada komentar:
Posting Komentar