Modul 1 Mikrokontroller dan mikroprocessor
byte sev_seg[] = {2,3,4,5,6,7,8,9};
void display_seven() // Pin 6,7,8 High and 2,3,4,5 Low to display 7
{
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}
void display_eight()// Pin 2,3,4,5,6,7,8 High to display 8
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
}
void setup() //Semua kode dalam fungsi ini hanya dieksekusi sekali
{
for(int i=0;i<9;i++)
{
pinMode(sev_seg[i],OUTPUT);
}
}
void loop() //Semua kode dalam fungsi ini di eksekusi berulang
{
display_seven();
delay(1000); // 1 s delay
display_eight();
delay(1000); // 1 s delay
}
Tidak ada komentar:
Posting Komentar