Senin, 04 Maret 2024

Tugas Pendahuluan 2

 




PERCOBAAN 5 KONDISI 6



1. Prosedur
[Kembali]

1.Rangkailah seperti rangkaian berikut 
2.Buka Arduino IDE dan masukan listing program Upload program ke arduino 
3.Variasikan tombol yang ditekan dan amati keluarannya pada LCD

2. Hardware dan Diagram Blok [Kembali]





Diagram Blok

3. Rangkaian Simulasi dan Prinsip Kerja [Kembali]



Sebelum disimulasikan



Setelah disimulasikan


Prinsip Kerja:

    Fungsi rangkaian ini adalah sebagai berikut: Dipswitch berfungsi sebagai input, di mana saklar pada dipswitch menghasilkan input analog yang dapat diubah menjadi digital; dual seven segment berfungsi sebagai output, yang menampilkan angka yang sesuai dengan saklar yang diaktifkan; dan kemudian setiap jumlah saklar yang aktif mempengaruhi output dual seven segment.


4. Flowchart dan Listing Program [Kembali]




Listing Program.


//M1P5 
#define a 6 
#define b 7 
#define c 8 
#define d 9 
#define e 10 
#define f 11 
#define g 12 
#define dp 13 
#define D1 4 
#define D2 5 
#define Dsw A0 
/*39 
32 
26 27 
19 
*/ 
int segments[] = {a,b,c,d,e,f,g}; 
byte digitPatterns[10][7] = { 
  {1, 1, 1, 1, 1, 1, 0}, // 0 
  {0, 1, 1, 0, 0, 0, 0}, // 1 
  {1, 1, 0, 1, 1, 0, 1}, // 2 
  {1, 1, 1, 1, 0, 0, 1}, // 3 
  {0, 1, 1, 0, 0, 1, 1}, // 4  
  {1, 0, 1, 1, 0, 1, 1}, // 5  
  {1, 0, 1, 1, 1, 1, 1}, // 6 
  {1, 1, 1, 0, 0, 0, 0}, // 7 
  {1, 1, 1, 1, 1, 1, 1}, // 8 
  {1, 1, 1, 1, 0, 1, 1}  // 9 
}; 
 
 
void setup() { 
  // put your setup code here, to run once: 
    
   for (int i = 0; i < 7; i++) { 
    pinMode(segments[i], OUTPUT); 
  } 
  pinMode(dp,OUTPUT); 
  pinMode(D1,OUTPUT); 
  pinMode(D2,OUTPUT); 
  pinMode(Dsw,INPUT_PULLUP); 
  Serial.begin(9600); 
 
void number (int display) { 
  if (display  >= 0 && display <= 9) { 
    for (int i = 0; i < 7; i++) { 
      digitalWrite(segments[i], digitPatterns[display ][i]); 
    } 
  } 
 
void loop() { 
 
  int sw = analogRead(Dsw); 
  Serial.print("ADC Value = "); 
  Serial.println(sw); 
  delay(100); 
 
 
  if(sw == 23){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(0); 
delay(50); 
  } 
else if(sw == 22){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(0); 
delay(1000); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(1); 
delay(1000); 
  }else if(sw == 21){ 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(0); 
delay(1000); 
number(1); 
delay(1000); 
number(2); 
delay(1000); 
number(3); 
delay(1000); 
number(4); 
delay(1000); 
number(5); 
delay(1000); 
number(6); 
delay(1000); 
number(7); 
delay(1000); 
number(8); 
delay(1000); 
number(9); 
delay(1000); 
  }else if(sw == 19){ 
digitalWrite(D1,HIGH); 
digitalWrite(D2,HIGH); 
number(0); 
delay(1000); 
number(1); 
delay(1000); 
number(2); 
delay(1000); 
number(3); 
delay(1000); 
number(4); 
delay(1000); 
number(5); 
delay(1000); 
number(6); 
delay(1000); 
number(7); 
delay(1000); 
number(8); 
delay(1000); 
number(9); 
delay(1000); 
  }else if(sw == 16){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(0); 
delay(500); 
number(1); 
delay(500); 
number(2); 
delay(500); 
number(3); 
delay(500); 
number(4); 
delay(500); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(5); 
delay(500); 
number(6); 
delay(500); 
number(7); 
delay(500); 
number(8); 
delay(500); 
number(9); 
delay(500); 
  }else if(sw == 13){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delayMicroseconds (500); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(0); 
delayMicroseconds (500); 
  }else if(sw == 10){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(9); 
delay(500); 
number(8); 
delay(500); 
number(7); 
delay(500); 
number(6); 
delay(500); 
number(5); 
delay(500); 
number(4); 
delay(500); 
number(3); 
delay(500); 
number(2); 
delay(500); 
number(1); 
delay(500); 
number(0); 
delay(500); 
  }else if(sw == 5){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(0); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(1); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(2); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(3); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(4); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(5); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(6); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(7); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(8); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 

number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(3); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(4); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(5); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(6); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(7); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(8); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(9); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(2); 

5. Video Demo [Kembali]
 
SAAT PRAKTIKUM.

6. Kondisi [Kembali]

P5K6 (Setiap 1 Switch aktif muncul angka berbeda pada digit ke 1, Setiap Switch aktif muncul angka pada kedua digit)


7. Video Simulasi [Kembali]




8. Link Download [Kembali].

Link Download HTML (klik disini)
Link Download Rangkaian (klik disini)
Link Download Video (klik disini)
Datasheet Datasheet (klik disini)
Arduino (klik disini)























Tidak ada komentar:

Posting Komentar

Entri yang Diunggulkan

  [ MENUJU AKHIR ] [KEMBALI KE MENU SEBELUMNYA] DAFTAR ISI 1. Pendahuluan 2. Tujuan 3. Alat dan Bahan 4. Dasar Teori 5. Perc...