Saturday 19 May 2012

LED Projects

I think, because I am a beginner, the best way to learn programming the microcontroller and familiarising with its inputs and outputs are by using simple LED programs. So I am making some simple LED projects and adding them here.

1. LED blinking - using Two LEDs.

A very basic one LED blink using Arduino is available in Arduino learning page. This one is using same ways but two LEDs fading in and out alternatively. I have used two PWM outputs to drive the LEDs. Each LED is connected to the PWM pin with a 220 Ohm resistor in series. See the video below.


2. 5 LED Filling/counting pattern.

This one is using the Arduino digital pins. The five LEDs are turned on and off using three 'for' loops and the delay() function. For this you may need the following things.
  1. 5 LEDs
  2. Arduino Uno
  3. Bread board
  4. Jumper leads (connecting leads)
  5. 5 Resistors (220 Ohm)
  6. And a Cup of tea!
See the video below.

This is a breadboard connection picture made with Fritzing. Fritzing is a software that I recently found out, very useful and easy. Brilliant application!!
And here is the schematic. I know, it is pathetic. This is the first time ever I used the Fritzing. I will get there, eventually!
And finally the code.
/********************************************************************************
void setup() {
  
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT); 
}

void loop() {
  
  for (int i=3; i < 8; i++)   //main counter
  {
      for(int j=3; j
      {
      digitalWrite(j,HIGH);
      delay(250);
      }
      for(int j=3; j
      {
      digitalWrite(j,LOW);
      }
      delay(250);
  } 

}
********************************************************************************/

No comments:

Post a Comment