Posts with «led interfacing with arduino» label

Using atmega 8 in Arduino IDE

This post is important since atmega 328p is way more expensive than atmega 8a. We can use arduino IDE with atmega 8 too.

Open arduino IDE and from file menu select Examples>Basics>Blink.
In next instance, code for blinking a led will be displayed on your screen.

Now from Tools>Board>Arduino NG or older

Selecting arduino ng or older

Now, we have to choose microcontroller:
Tools>Processor>Atmega 8

Selecting atmega 8
Now, we have to just compile the program.
Just click on the first icon just below the file menu.
Compiling the code
Also, make some changes in preferences: File>Preferences
Preferences
Make changes as given above. This make the IDE more user-friendly.
Note: Preferences has nothing to do with programming part. It just makes IDE more user-friendly.

Now, our hex file is generated. One question arises: How to locate the hex file?

First of all, click on view to display hidden files and folders:
View hidden files and folders
After this, hidden files and folders will appear: 
You can retrieve hex file from the following directory:

C:\Users\user_name\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp

In this folder, resides your hex file. Check the date and time of hex file.

I am using avrdudes for burning the hex file in atmega 8a.

Fuse byes are as follows: Low fuse: 0xE4
                                         High fuse: 0xC6
This setting is for 8-MHz internal oscilltor.

Note: Wrong fuse bytes can damage your microcontroller.
The delay of arduino IDE is not in sync with your coding due to indifference in crystal oscillator.

Thanks for your patience.

Keep supporting !!




Led blinking with Arduino Uno

Let's start with led blinking in arduino

Led Blinking Code
Schematics using Fritzing
You can download the source code from the following link:

https://drive.google.com/file/d/0B4Px6Drl6Zz_Z3ZfaGhIallGUnc/view?usp=sharing

The code is self explanatory. Pin number 13 of arduino is configured as output. cost int led=13
makes it a read only variable and also pin number 13 is named as led.
You can use any digital pins i.e from 0 to 13. We have taken pin number 13 because the in-built led of arduino is connected to pin number 13. If you are going to use any other pin please don't forget to connect the external resistor having a minimum value of 220 ohm resistance.

delay(1000)   // It provides a delay of 1000 ms i.e. 1s

Now coming to the calculation of resistance, it is as per according to Ohm's law:

V==IR

The led have forward current of  about 25 milli Amps and voltaage provided by arduino is +5 volts
I = V/R  ....... I  = 5000/25, which comes out to 200 ohms. But this is not a standard value and the nearby value is 220E. Feel free to comment here.