Running LED di Arduino

Ditulis oleh agan

بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم

Di kesempatan kali ini saya akan menjelaskan bagaimana membuat sebuah RUNNING LED dengan Arduino. ini adalah tutorial dasar Arduino yang cocok buat Pemula Arduino.

Alat dan Bahan yang dibutuhkan :
  • 1x Arduino Uno
  • 6x Resistor 330 ohm
  • 6x LED ( Warna Bebas )
  • 1x Breadboard
  • 8x Kabel Jumper
Langkah-langkahnya :

1 .) Susun rangkaian seperti gambar berikut pada breadboard




Keterangan :
  • Pin 3 Arduino di jumper ke kaki LED 1 ( Positif ) pada breadboard.
  • Pin 4 Arduino di jumper ke kaki LED 2 ( Positif ) pada breadboard.
  • Pin 5 Arduino di jumper ke kaki LED 3 ( Positif ) pada breadboard.
  • Pin 6 Arduino di jumper ke kaki LED 4 ( Positif ) pada breadboard.
  • Pin 7 Arduino di jumper ke kaki LED 5 ( Positif ) pada breadboard.
  • Pin 8 Arduino di jumper ke kaki LED 6 ( Positif ) pada breadboard.
  • Lalu hubungkan semua resistor pada breadboard, lalu di jumper ke pin GND Arduino.
2.) Setelah itu sambungkan Arduino pada Laptop/PC dengan menggunakan kabel serial.
3.) Download dan Install program Arduino IDE di Arduino.cc ( If Needid )
4.) Setelah terinstall, jalankan program Arduino-nya.
5.) Klik menu "Tools -> Board -> Arduino Uno"
6.) Klik menu "Tools -> Port -> ( Pilih Port arduino yang terdeteksi di komputer anda )
7.) Lalu masukan Sketch dibawah ini.

Klik show untuk melihat code
// variables
int LED1 = 3;
int LED2 = 4;
int LED3 = 5;
int LED4 = 6;
int LED5 = 7;
int LED6 = 8;
int DELAY_LED = 100;

// Setting Sebagai Output
void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
}

void loop()
{
  digitalWrite(LED1,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED6,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
}

8.) Lalu upload sketch, dan lihat hasilnya akan seperti video dibawah ini.


Atau anda bisa pakai sketch dibawah ini untuk running LED yang berbeda nyala LED nya.


Klik show untuk melihat code Running LED part 2
// variables
int LED1 = 3;
int LED2 = 4;
int LED3 = 5;
int LED4 = 6;
int LED5 = 7;
int LED6 = 8;
int DELAY_LED = 30;
int DELAY_RUN = 100;
int DELAY_ZIGZAG = 200;
int DELAY_LED1 = 300;

// functions
void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
}

void loop()
{
  digitalWrite(LED1, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED6,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED1);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED6, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED1,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED1);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED1, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED6,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED1);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED6, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4, HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED1,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED2,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED3,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED4,HIGH);
  delay(DELAY_LED);
  digitalWrite(LED5,HIGH);
  delay(DELAY_LED1);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED);
  digitalWrite(LED2,LOW);
  delay(DELAY_LED);
  digitalWrite(LED3,LOW);
  delay(DELAY_LED);
  digitalWrite(LED4,LOW);
  delay(DELAY_LED);
  digitalWrite(LED5,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED2,HIGH);
  delay(DELAY_RUN);
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED3,HIGH);
  digitalWrite(LED4,HIGH);
  delay(DELAY_RUN);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED5,HIGH);
  digitalWrite(LED6,HIGH);
  delay(DELAY_RUN);
  digitalWrite(LED5,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED4,HIGH);
  digitalWrite(LED3,HIGH);
  delay(DELAY_RUN);
  digitalWrite(LED4,LOW);
  digitalWrite(LED3,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED1,HIGH);
  delay(DELAY_RUN);
  digitalWrite(LED2,LOW);
  digitalWrite(LED1,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED6,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED1,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED5,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED2,LOW);
  digitalWrite(LED5,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED3,HIGH);
  digitalWrite(LED4,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED5,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED2,LOW);
  digitalWrite(LED5,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED6,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED1,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_RUN);
    digitalWrite(LED1,HIGH);
  digitalWrite(LED6,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED1,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED5,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED2,LOW);
  digitalWrite(LED5,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED3,HIGH);
  digitalWrite(LED4,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED5,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED2,LOW);
  digitalWrite(LED5,LOW);
  delay(DELAY_RUN);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED6,HIGH); 
  delay(DELAY_RUN);
  digitalWrite(LED1,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_LED1);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED3,HIGH);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED1,LOW);
  digitalWrite(LED3,LOW);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED4,HIGH);
  digitalWrite(LED6,HIGH);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED4,LOW);
  digitalWrite(LED6,LOW);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED5,HIGH);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED2,LOW);
  digitalWrite(LED5,LOW);
  delay(DELAY_ZIGZAG);
  digitalWrite(LED1,HIGH);
  digitalWrite(LED3,HIGH);
  digitalWrite(LED4,HIGH);
  digitalWrite(LED6,HIGH);
  delay(DELAY_LED1);
}

Terimakasih sudah berkunjung, Semoga Bermanfaat.

Blog, Updated pada: 12:00:00
Comments
0 Comments

0 comments:

Post a Comment

Masih Bingung atau Hal Lainnya? Silahkan Bertanya di Kolom Komentar :)

~ Dilarang SARA
~ Dilarang PORNOGRAPHY
~ Dilarang SPAM
~ Dilarang MENINGGALKAN LINK AKTIF
~ Maaf untuk Anonymous, tidak bisa Berkomentar.

Apabila Komentar anda belum muncul, Tunggu sampai di Moderasi.
Terimakasih atas Perhatiannya.


English French German Spain Italian Dutch Russian