Monday 19 January 2015

Blink code in Arduino ( Blink LED ON and OFF using Arduino)


/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}




The following code is available by default in Arduino in File---->Examples---->basics----->blink

Working of the code

The pin 13 avail in the Arduino UNO has a On-board LED with a internal resistance with it .
so in order to activate the internal resistance the code " pinMode(led,OUTPUT) "(in void setup) is used.
The variable led is initialized with 13 and the pin 13 is said to be a output.
So the resistance of the on board LED is activated.


Now in void loop()  the code

digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 
supplies 5v(ie Vcc) to the LED and hence it glows up..!! :D
now it has a delay(1000) which waits for one second and again it switches off the LED and waits for 1 sec.

This process repeats for ever in void loop()..!!



Getting Started with Arduino


The Arduino environment has been designed to be esy to use for beginners who have no software or electronics Xp's unlike me..!!With Arduino you can build objects that can respond to and/or control lights,sound,touch and movement..(What else do you probably need???)
So you can use Arduino to create your own musical instruments,Robots,light sculptures,games,interactive furniture and even interactive clothing .

Arduino is used in many educational programs around the world,particularly by designers and artists who want ot easily create prototypes but do not need a deep understanding of the technical detailes behind their creations.Because it is designed to be used by non-tech people the software includes plenty of example code to demonstrate how to use the Arduino board .

Arduino Software

Software programs called sketches are created on a computer using the Arduino IDE . The IDE enables you to write and edit code and convert this code into instructions that Arduino hardware understands.The IDE also transfers those instructions to the Arduino board.

Arduino Hardware Spec

 https://h4ckr-naren.blogspot.com/b/post-preview?token=g0a3BEsBAAA.hbmbliLvBIZwcMUU5Tb13A.wnqBlh_p3a-9M-dhxu5rRw&postId=7426553885776567980&type=POST