LAPORAN AKHIR 1 (MODUL I GENERAL INPUT DAN OUTPUT)




Modul I GENERAL INPUT DAN OUTPUT


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


Diagram Blok






Rangkaian Simulasi



Prinsip Kerja
    Rangkaian ini berfungsi sebagai berikut: DipSwitch berperan sebagai input, di mana saklar pada dipswitch akan menghasilkan input analog yang akan diubah menjadi digital. dual seven segment berfungsi sebagai output, menampilkan angka yang sesuai dengan saklar yang diaktifkan . 
    dan setiap jumlah saklar yang aktif akan mempengaruhi output yang akan ditampilkan oleh dual seven segment.


Flowchart






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] = { 
{0, 0, 0, 0, 0, 0, 1}, // 0
{1, 0, 0, 1, 1, 1, 1}, // 1
{0, 0, 1, 0, 0, 1, 0}, // 2 
{0, 0, 0, 0, 1, 1, 0}, // 3 
{1, 0, 0, 1, 1, 0, 0}, // 4
{0, 1, 0, 0, 1, 0, 0}, // 5
{0, 1, 0, 0, 0, 0, 0}, // 6 
{0, 0, 0, 1, 1, 1, 1}, // 7 
{0, 0, 0, 0, 0, 0, 0}, // 8 
{0, 0, 0, 0, 1, 0, 0} // 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 == 1023){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(1); 
delay(50); 

digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(0); 
delay(50); 
  } 
else if(sw > 35 && sw <38){ 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(0); 
delay(1000); 
digitalWrite(D1,HIGH); 
digitalWrite(D2,LOW); 
number(1); 
delay(1000); 
  }else if(sw > 38 && sw <41){ 
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 > 24 && sw <29){ 
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 > 19 && sw <24){ 
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(9); 
delay(50); 
digitalWrite(D1,LOW); 
digitalWrite(D2,HIGH); 
number(2); 
}





    P5 (Dipswitch sebagai Input dan output oleh dual seven segment)




File HTML klik disini
Rangkaian Simulasi Proteus klik disini
File Video Rangkaian klik disini
File Arduino klik disini
Datasheet  klik disini
 








Tidak ada komentar:

Posting Komentar