Hello friends...!!! This is my first tutorial on Instructables, in this tutorial I'm going to show you

* Write a simple program for glowing LED
* Group of LED program
* Explain analog output (PWM)
* Create a simple project of (4 bit binary counter).

Small BIO:
Friends we know that arduino is a powerful tool with infinite abilities !,,. so in my later tutorials I will boost my progress in making complex projects like robotics. Myself and 3 others..who are my friends are from a organization called "Electronics Made Simple". We like to create a beautiful world of electronics. Here is our link http://electronicsmadesimplee.blogspot.in/


Step 1: Materials Required

  • 1 x Bread board
  • 4 x LED
  • 4 x 1k ohm resistors
  • Arduino UNO r3
  • USB cable of Arduino.

Friends this is enough for doing all the things specified in this tutorial,,,!!!!!!!!!!

NOTE : I have used a led array on strip board for my convenience SORRY......Besides that you can design the led array on bread board itself.

Step 2: Schematics

Friends these are the schematics for glowing LED'S. PWM is a seprate thing so that I have highlighted the specific (figure no2).

Step 3: Glowing a Single LED

The thumbrule is that writing a "Simple program" to understand thehiearchy of Arduino programming.

  • The Setup Function
The next stage in creating any sketch is to add the void setup() function. This function contains a set of instructions for the Arduino to execute once only, each time it is reset or turned on. To create the setup function, add the following lines to your sketch.

void setup()

  • Controlling the Hardware
Our program will blink the user LED connected to pin 2. A digital pin can either detect an electrical signal or generate one on command. In this project, we’ll generate an electrical signal that will light the LED. This may seem a little complicated, but you’ll learn more about digital pins in future chapters. For now, just continue with creating the sketch. The number 2 in the listing represents the digital pin you’re addressing. You’re setting this pin to OUTPUT, which means it will generate (output) an electrical signal. If you wanted it to detect an incoming electrical signal, then you would use INPUT instead

void setup()
pinMode(2, OUTPUT); // set digital pin 2 to output

  • The Loop Function
Remember that our goal is to make the LED blink repeatedly. To do this, we’ll create a loop function to tell the Arduino to execute an instruction over and over until the power is shut off or someone presses the RESET button.
void loop()
// place your main loop code here:

  • Summing up
void setup()
pinMode(2, OUTPUT); // set digital pin 2 to output
void loop()
digitalWrite(2, HIGH); // turn on digital pin 2
delay(1000); // pause for one second
digitalWrite(2, LOW); // turn off digital pin 2
delay(1000); // pause for one second

Thats all friends I hope you completed the first task of lighting up and off of LED.This is the basis for all the further concepts.

Step 4: Glowing Multiple LED

In this section it's time to hook up multiple LED with our Arduino. We can use 1k ohm resistor for current limiting...so that our LED stays alive :)

When interfacing multiple LED'S with Arduino we can follow the same procedure for glowing a single LED from step 3.The concept of programming is same, whilst you have to keep in mind that multiple LED'S are used. I have uploaded a simple program for glowing 4 LED'S with some (delay of half second).

Algorithm :
  • Initialize void setup function.
  • create a repeating loop function.

Thats all friends you have successfully made group of LED glow.

Step 5: For Loop Usage

  • For loop :
When designing a sketch, you’ll often repeat the same function. You could
simply copy and paste the function to duplicate it in a sketch, but that’s inefficient and a waste of your Arduino’s program memory. Instead, you can use for loops. The benefit of using a for loop is that you can determine how many times the code inside the loop will repeat. I have made for loop inside the sketch for pins 2 to 5. This technique hepls to reduce the program memory.

Friends now we have seen sor far glowing a single LED then multiple and finally to use (for loop) in Arduino programming. lets move on!!!!!

Step 6: PWM OUTPUT (pulse Width Modulation)

Arduino UNO has about 14 input and output pins of which 6 are analog outputs(PWM) pins. And there are about 6 analog inputs which are ADC'S. The PWM pins give analog output which is used in majority of projects.In this tutorial we are going to demonstrate with the help of LED'S.

  • Varying LED Brightness with Pulse-Width Modulation :
    Rather than just turning LEDs on and off rapidly using digitalWrite(), we can define the level of brightness of an LED by adjusting the amount of time between each LED’s on and off states using pulse-width modulation (PWM). PWM can be used to create the illusion of an LED being on at different levels of brightness by turning the LED on and off rapidly, at around 500 cycles per second. The brightness we perceive is determined by the amount of time the digital output pin is on versus the amount of time it is off—that is, every time the LED is lit or unlit. Because our eyes can’t see flickers faster than 50 cycles per second, the LED appears to have a constant brightness.

OK friends I think I have given everything that you should know about LED programming.The next part is going to be very intresting we are going to make a project based on the things that we have learned. :)

Step 7: 4 Bit Binary Counter

If you are a electronics engineer you should know binary counter program....Well it's a crime if you don't know...beacuse these things are the very basic of every digital systems LOL :).....Cool,!!!! it's a easy concept if you look at it.
Guys lets get started to it..............


"If you observe 4 bit sequence it is well understood that LSB is toggling every cycle while the bit next to it is toggling every 2 cycles and bit next to it toggles at every 4 cycle to achieve this effect we use MOD operator %"...and so on if you can imagine... :)
Remember friends this forms the basis for any number of BINARY SEQUENCES.

Counter%2 for LSB ie ( 01010101010101...)
(Counter/2)%2 for (00110011....)
(Counter/4)%2 for (0000111100001111....)
(Counter/8)%2 for MSB (0000000011111111)

Guys that's the concept....>> just go ahead and don't be afraid !!!!!! to add up some more LED'S to create 5 bit binary or 6 bit binary counter. :) :) Afterall you have Arduino.............Break the barriers....
Thank you..hope you like my tutorial see ya guys.....!!!! Happy Arduinoing.

<p>This is a very good ible as I am just starting out with arduino. thank you very much for sharing.</p><p>John :)</p>
<p>Thank You Mr.Abrezengineer :)</p>

About This Instructable




Bio: I am tech geek and I don't like to follow the crowd but I like to create a new path,..Perseverance is my armour ... More »
More by abrezengineer:Arduino Insight -Beginner LED'S and (Binary counter 16 bit) 
Add instructable to: