Introduction: Arduino Simple LED Animation (For Beginners)

About: I want to learn more more and more..! Its my Dream, Hobby, Passion and Obsession.

Hello friends. I am back with another Arduino project that showyou how to have a basic blink animation using 5 leds and an Arduino. This one is quite simple intented for beginners to help learn Arduino Basics.

So here we go,

Step 1: Make It Simple

So connect the circuit as shown in the diagram.

Positive side of each led goes to a 220OHM resistor with further goes to its corresponding pins on the Arduino. DON'T MESS UP THE PINS ON ARDUINO AS YOU HAVE TO CHANGE THE PIN NUMBERS IN THE CODE TOO. SO AVOID IT.

Connect all the negative sides to one and connect that to the GND pin on the Arduino.

And That's All.

HERE IS THE CODE:

//Created By Muhammad Hussnain

void setup() { // initialize digital pin 13 as an output. pinMode(2, OUTPUT); pinMode(4, OUTPUT); pinMode(6, OUTPUT); pinMode(8, OUTPUT); pinMode(10, OUTPUT); }

void loop() { for(int i = 2; i <= 10; i+=2) { digitalWrite(i, HIGH); delay(500); digitalWrite(i, LOW); delay(500); }

for(int x = 1; x <= 5; x++) { for(int i = 2; i <= 10; i+=2) { digitalWrite(i, HIGH); delay(80); digitalWrite(i, LOW); delay(80); } } delay(500); for(int k = 1; k <= 5; k++) { digitalWrite(2, HIGH); digitalWrite(4, HIGH); digitalWrite(6, HIGH); digitalWrite(8, HIGH); digitalWrite(10, HIGH); delay(250); digitalWrite(2, LOW); digitalWrite(4, LOW); digitalWrite(6, LOW); digitalWrite(8, LOW); digitalWrite(10, LOW); delay(250); } delay(500); }