You are on page 1of 7

PROYEK 2 :

( Animasi Lampu LED )

Disusun Oleh :
Moranain Mungkin, ST, M.Si
Alat dan Bahan :

• 8 Buah LED
• 8 Buah Resistor 560 Ω
• 9 Buah Kabel Jumper
• 1 Buah Protoboard
• 1 Buah Arduino
• 1 Buah Kabel USB Printer
• 1 Buah Komputer / Laptop
• Software Arduino IDE
WIRING SISTEM :
Keterangan :

• Pin GND Arduino (Warna Hitam) ke GND LED


(Warna Hitam)
• Pin 4 – Pin 11 dihubungkan ke Positif LED melalui
Resistor 560 Ohm
• AC/DC Adaptor dihubungkan ke port Power Arduino
(Female)
• Kabel USB printer tipe B dihubungkan dengan Port
USB Arduino
• Kabel USB printer tipe A dihubungkan dengan Port
USB Laptop
Sketch Program :
Sketch Program :
byte pinled[] = {4,5,6,7,8,9,10,11};
int waktu_tunda(1000);
int arah = 1;
int posled = 0;
unsigned long perubahanwaktu;

void setup() {
for(int x = 0; x < 8; x++){
pinMode(pinled[x],OUTPUT);}
perubahanwaktu = millis();
}

void loop() {
if ((millis() - perubahanwaktu) > waktu_tunda){
perubahanLED();
perubahanwaktu = millis();

}
}
void perubahanLED(){
for (int x=0; x<7; x++){
digitalWrite(pinled[x], LOW);
}
digitalWrite(pinled[posled], HIGH);
posled +=arah;
if (posled == 7) {arah = -1;}
if (posled == 0) {arah = 1;}
}
TERIMAKASIH

You might also like