Kamis, 01 Oktober 2020

Pemrograman 7-Segment dengan arduino

 Pemrograman 7-Segment dengan arduino


Berikut ini tutorial cara mengaktifkan 7-Segment pada arduino



//----- Program 5 : tampilan angka 3 pada digit 1

void setup() {               

  pinMode(2, OUTPUT);     pinMode(3, OUTPUT);

  pinMode(4, OUTPUT);    pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);    pinMode(7, OUTPUT);

  pinMode(8, OUTPUT);    pinMode(9, OUTPUT);  

  pinMode(10, OUTPUT);    pinMode(11, OUTPUT);   

  pinMode(12, OUTPUT);      pinMode(13, OUTPUT);    

}   


void loop() { 

  digitalWrite(10,0);

  digitalWrite(11,1); 

  digitalWrite(12,1);  

  digitalWrite(13,1);   

  

  digitalWrite(2,0);  

  digitalWrite(3,0);

  digitalWrite(4,0);

  digitalWrite(5,0);

  digitalWrite(6,1);

  digitalWrite(7,1);

  digitalWrite(8,0);

  digitalWrite(9,1);    

}



//----- Program 6 : tampilan angka 2 pada digit 2
void setup() {               
  pinMode(2, OUTPUT);  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);  pinMode(9, OUTPUT);  
  pinMode(10, OUTPUT); pinMode(11, OUTPUT);    
  pinMode(12, OUTPUT); pinMode(13, OUTPUT);    
}   
void loop() { 
  digitalWrite(10,1);  digitalWrite(11,0);  
  digitalWrite(12,1);  digitalWrite(13,1);    
  digitalWrite(2,0);  digitalWrite(3,0);
  digitalWrite(4,1);  digitalWrite(5,0);
  digitalWrite(6,0);  digitalWrite(7,1);
  digitalWrite(8,0);  digitalWrite(9,1);   
}



//----- Program 7 : tampilan angka ‘0123’
void setup() {               
  pinMode(2, OUTPUT);  
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);  
  pinMode(10, OUTPUT);    
  pinMode(11, OUTPUT);    
  pinMode(12, OUTPUT);  
  pinMode(13, OUTPUT);    
}   
void loop() { 
  digitalWrite(10,0);
  digitalWrite(11,1); 
  digitalWrite(12,1);
  digitalWrite(13,1); 
  //---tampilan angka 0
  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,0);
  digitalWrite(6,0);
  digitalWrite(7,0);
  digitalWrite(8,1);
  digitalWrite(9,1);  
  delay(5);
  digitalWrite(10,1);
  digitalWrite(11,0);
  digitalWrite(12,1);
  digitalWrite(13,1);  
  //---tampilan angka 1
  digitalWrite(2,1);
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,1);
  digitalWrite(6,1);
  digitalWrite(7,1);  
  digitalWrite(8,1);
  digitalWrite(9,1);  
  delay(5);
  digitalWrite(10,1);
  digitalWrite(11,1);
  digitalWrite(12,0);
  digitalWrite(13,1);  
  //---tampilan angka 2
  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,1);
  digitalWrite(5,0);
  digitalWrite(6,0);
  digitalWrite(7,1);
  digitalWrite(8,0);
  digitalWrite(9,1);  
  delay(5);
  digitalWrite(10,1);
  digitalWrite(11,1);
  digitalWrite(12,1);
  digitalWrite(13,0);  
  //---tampilan angka 3
  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,0);
  digitalWrite(6,1);
  digitalWrite(7,1);
  digitalWrite(8,0);
  digitalWrite(9,1);  
  delay(5);
 }


Tidak ada komentar:

Posting Komentar