“Hello, DIGITAL World!” with Arduino

0

So guys let’s start with Arduino!

In this post, the focus will be to introduce Arduino as well as giving an insight in Electronics and breadboard prototyping!.

Take care you have following things before you start ahead:-

  • Arduino Board (preferably UNO)
  • Some LEDs
  • One Breadboard
  • Wires (preferably 22-24 gauge)
  • USB cable
  • Resistors

Objective:Controlling the LED on Arduino!

Pre-essentials: One just need to have very basic or even no knowledge of electronics, although programming background will make it easier.

Here we go:-

Let me tell you an interesting thing there is already an inbuilt LED on pin 13 of your Arduino board

 

So we will be controlling that LED  on PIN 13 which is quite clear from schematics

As in any programming language there is a bare minimum which means at-least that part is to be in program

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

/*
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
}

Copy paste this code in your ARduino IDE a and upload it to your Arduino using upload button on Arduino obviously by connecting the USB  to your Board

 

 

So it is the time to Decode the code and see how  amazing software allow us to interfere with electrical circuits.

int led =  13;

This creates a variable name of type int and declares that we  want to use pin 13 on arduino.

 pinMode(led, OUTPUT);    

There is a function in arduino that let us decide what we want to do with pins or i/p-o/p pins, whether we want to take something from them or we want to feed something inside them.

Particularly in this example since we want to make the LED blink, we have declared the led pin or the pin 13 as output.

 digitalWrite(led, HIGH); 

In  digital world there are only two values either on/off, high/low, 1 or 0.

digitalWrite  allows us to decide whether we want to activate or make a pin HIGH  or vice verse  .

 delay(1000);   

delay() is a function which delays the act up to particular timings , by default it takes time in milliseconds so we have make the led lit for 1 second and then off.

Well, i think it is enough for this tutorial , go ahead and explore yourself  http://arduino.cc/.

Also check out our tutorial: Don’t be quite, Make noises with Arduino!

Get the best of Durofy in your inbox

Share.

About Author

Comments are closed.