Skip to main content

Arduino: Blinking LED

First up blinking LED! Blinking LED is the basic and the first thing you should learn.First let us connect the Arduino to the computer.

Then start the arduino IDE. if you do not have the IDE, then visit the Arduino Website and download it.when you open the arduino IDE you will see the following window.

Arduino IDE

Now go to tools, boards and then select the board you are using. I am using a Arduino duemilanove.


Arduino Duemilanove

Now go to tools, Serial port and select the port to which you have connected. If you dont know the port just select one port and upload the program. If you get an error then change the port until the program gets uploaded.

now let us write a program to blink the LED. By default, there is an LED connected to Pin 13 on the board. So for testing we do not require any other peripherals.

Start typing the following lines of code. The following code is in C language.

Code:

void setup(){    // What ever is written within these brackets are executed once.

pinMode(13, OUTPUT); // We are declaring that pin 13 is output.

}

void loop(){ // What ever is written within these brackets are executed again and again.

digitalWrite(13, HIGH); // We are declaring that pin 13 is ON.
delay(1000); // Wait for 1000ms
digitalWrite(13, LOW); // We are declaring that pin 13 is OFF.
delay(1000); // Wait for 1000ms

}


After typing the above code click on upload. The compiler will compile and uploads it to the micro-controller. After a few secconds the program will execute and the led on the arduino board will start to blink. My board takes three seconds after switching on to execute the program.








Comments

Popular posts from this blog

Switch debouncer using SR Latch

We use switch in our day to day life to switch ON/OFF a bulb or a fan or  any electrical devices. But when we use switches in digital circuits, we observe a phenomenon called bouncing. This occurs because, when we turn the switch, the mechanical parts vibrate. i.e It toggles between ON and OFF state for some time until the mechanical contact attain equilibrium. this vibrations are minute and are not at all noticeable in electrical circuit. where as in digital circuits, these vibrations create pulses. which are detected by circuits which results in an error.               In the above circuit, there is a switch connected to VCC. You can toggle it between terminal 'a' and terminal 'b'. which as a voltage drop of 'Va' and 'Vb' respectively. In digital circuits if you can observe, it takes a finite amount of time to toggle between terminal 'a' and 'b'. which might approximately take 15ns. Now let us consider the terminal is at 'a'. we...

ADXL 355 Accelerometer

A few days ago I went to get components for a project I was building. and came across a 3-axis accelerometer. So I decided to test it and make a post to give you an idea of things work and how you can use it. ADXL 355                   The accelerometer I have is ADXL 355 v2.0 board. there is are 5 headder pins, ground, 5V supply, X-axis output,Y-axis output and Z-axis output. It is quite compact. The one I have measured around 15mm x 15mm. These sensors are low cost. And can be incorporated in Projects or robots we build. The ADXL 355 board I have has an onboard Red led (smd) for the indication of power. The accelerometer has a wide range of applications. ADXL 355 is a basic accelerometer which gives analog values for all the three axis depending upon the position of the IC. ADXL 345 is an advanced accelerometr which can detect free-fall,activity,tap,double tap and communicates via I2C. The ADXL is a a ultra-lowpower as it consumes only 25 u...

Latch using JK Flip Flop

In this post we will learn how to use JK flip flop as a latch. i.e. for one pulse, the circuit continues to stay in the ON state until the next pulse. and the circuit continues to be in the OFF state till the next pulse. This can be achieved by using toggle mode in JK flip flop. TRUTH TABLE: IC 7476 J       k       set '      reset'        Q      Q' 1       1        1            1               Toggle IC CD4026 J       k       set       reset         Q      Q' 1       1        0           0               Toggle Note: Set is referred as PRE or preset. Reset is referred as CLR or clear. Refer the Datasheet of the JK flip flop you are using ...