Sunday, 22 June 2014

My First Project-BLINK

Being an ECE student having not gone to any intern, I thought of doing some projects while on my vacation. I found arduino as a good platform to start with. I downloaded the arduino IDE from this link   http://arduino.cc/en/Main/Software . After installing the software, we need to initialize the serial port to which arduino is connected..Here I begin :D :D

So What is Arduino?

From the Arduino.cc homepage:
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Blinking 5 LEDs in a row for a second each

This is the most basic arduino project. You can use the inbuilt L-LED connected to 13th pin of the arduino board or connect external led.

Arduino code consists of two parts basically:
1. setup() : it runs when the arduino is initialized(reset)
2. loop(): it runs till arduino is off.

  • pinMode is the command to assign a pin of arduino board to either input or output mode
  • digitalWrite is used to set a pin to digital High (on) or low (off)
  • delay( ) takes the value in milliseconds for delay

Breadboard Layout:


Code:


/* My First Program */

int pin2=2;
int pin3=3;
int pin4=4;
int pin5=5;
int pin6=6;

void setup()
{
  pinMode(pin2, OUTPUT);
   pinMode(pin3, OUTPUT);
    pinMode(pin4, OUTPUT);
     pinMode(pin5, OUTPUT);
      pinMode(pin6, OUTPUT);

}
void loop()
{
   digitalWrite(pin2, HIGH);
  delay(1000);
  digitalWrite(pin2, LOW);
  delay(1000);
     digitalWrite(pin3, HIGH);
  delay(1000);
  digitalWrite(pin3, LOW);
  delay(1000);
     digitalWrite(pin4, HIGH);
  delay(1000);
  digitalWrite(pin4, LOW);
  delay(1000);
     digitalWrite(pin5, HIGH);
  delay(1000);
  digitalWrite(pin5, LOW);
  delay(1000);
     digitalWrite(pin6, HIGH);
  delay(1000);
  digitalWrite(pin6, LOW);
  delay(1000);
}

Output:



No comments:

Post a Comment