Percobaan 2 Kondisi 3 : Tampilkan angka dari 9 sampai 1 secara berulang.
Setelah kita membuat rangkaian simulasi pada proteus sesuai dengan yang dicontohkan pada modul, maka selanjutnya kita akan membuat program arduino sesuai dengan percobaan 2 kondisi 3 yaitu sebagai berikut :
byte pin[]={2,3,4,5,6,7,8,9};
void setup()
{ for(int i = 0;i<9;i++)
{
pinMode(pin[i],OUTPUT);
}
}
void loop()
{
//9
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,HIGH);//f
digitalWrite(5,LOW);//e
digitalWrite(6,LOW);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,HIGH);//b
digitalWrite(9,HIGH);//a
delay(1000);
//8
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000);
//7
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000);
//6
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,HIGH);//f
digitalWrite(5,HIGH);//e
digitalWrite(6,HIGH);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,LOW);//b
digitalWrite(9,HIGH);//a
delay(1000);
//5
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,HIGH);//f
digitalWrite(5,LOW);//e
digitalWrite(6,HIGH);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,LOW);//b
digitalWrite(9,HIGH);//a
delay(1000);
//4
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,HIGH);//f
digitalWrite(5,LOW);//e
digitalWrite(6,LOW);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,HIGH);//b
digitalWrite(9,LOW);//a
delay(1000);
//3
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,LOW);//f
digitalWrite(5,LOW);//e
digitalWrite(6,HIGH);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,HIGH);//b
digitalWrite(9,HIGH);//a
delay(1000);
//2
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,LOW);//f
digitalWrite(5,HIGH);//e
digitalWrite(6,HIGH);//d
digitalWrite(7,LOW);//c
digitalWrite(8,HIGH);//b
digitalWrite(9,HIGH);//a
delay(1000);
//1
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);//a
delay(1000);
}
//9
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);//g
digitalWrite(4,HIGH);//f
digitalWrite(5,LOW);//e
digitalWrite(6,LOW);//d
digitalWrite(7,HIGH);//c
digitalWrite(8,HIGH);//b
digitalWrite(9,HIGH);//a
delay(1000);
Tidak ada komentar:
Posting Komentar