Friday, 29 April 2016

Interfacing temperature sensor with arduino

Interfacing temperature sensor (LM35) with arduino:

In this post, we will learn how to interface temperature sensor (LM35) with arduino uno.

Arduino Uno is an open-source electronic prototype board used by beginners, hobbyists and developers across the globe, Arduino have so many forums, if you need any help, guidance.
Arduino uno is based on atmega 328p microcontroller. Arduino uno comes in two pckages:
Through-hole package and SMD package.

For the time being, we are considering through-hole package. It's a 28-pin DIP (dual inline package) IC.  There are 14-digital I/O pins and 6-analog input pins.
Arduino has a rich library support. For example: led blinking, lcd interfacing, etc. all these program can br found in library.

In order to display data received from temperature esnsor, we need display device like seven segment display or lcd or alternatively we can use serial monitor.

LM-35 is a temperature sensor. It's sensitivity is 10mV/°C which literally means with rise in temperature by 1° Celsius the voltage is increased by 1 millivolts. It's graph is linear.
It's range is from -55° Celsius to +150° Celsius.

Arduino have 6-adc channels viz, A0-A5. These are 10-bit adc means 0-5 analog volt is converted into digital count ranging from 0-1023

Resolution = Vref/((2^10)-1) = Vref/1023

We are taking Vref as 5 volt. Now, the resolution comes out to be 4.887 mV

In order to convert digital count into voltage, we have to multiply it by 4.887. Now we have voltage. We have to convert this voltage into temperature. This is known as calibration.

Temperature in ° C = 4.887 * digital count (0-1023) /10.0

Here are the screenshots of prteus simulation and code:

Interfacing temperature sensor with arduino proteus simulation
Proteus simulation

Download arduino code and simulation from the link given below:

Stay tuned for more updates !!


Wednesday, 27 April 2016

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

Arduino ng or older
Selecting arduino ng or older

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

Selecting atmega8 from processor
Selecting atmega 8
Now, we have to just compile the program.
Just click on the first icon just below the file menu.
compile the code
Compiling the code
Also, make some changes in preferences: File>Preferences
Arduino 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:
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:


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 !!

Wednesday, 6 April 2016

Simulating arduino uno in proteus

By default, proteus don't have any library for arduino.

First of all, install library for proteus using the previous post Arduino library

Now, one problem arises how to get hex file of our program.

It lies in the following directory:
C:\Users\ \AppData\Local\Temp

You can make a shortcut of temp folder on your desktop to easily access it. By default, temp folder is hidden you have to unhide it.

This picture will make it simple

file directory for arduino hex file
File directory
In proteus, double click on arduino uno. It will pop-up a window named edit component on program file click on browse icon to browse your hex file.
Browsing hex  file for proteus simulation
Browsing hex file
Always double the time and date of your hex file to ensure that are using correct file.

Thanks for giving your valuable time.

Stay tuned for more updates !!

Interfacing lcd with arduino

How to interaface lcd (4-bit interface) with arduino?

In this tutorial, we are going to discuss , how to interface lcd with arduino.

We are using 16*2 lcd, means it have two rows and 16 columns. Overall, we can display 32 characters.
16*2 alphanumeric lcd
16*2 LCD

Lcd have 16 pins, out of which six are connected to arduino. D4-D7 are data pins. RS, RW and EN pins are also there. RW pin is permanently grounded since we are writing to lcd.
Pin no 3 is connected to pot (10k) in order to change the contrast. Pin no 15 and 16 are for backlight.
Since lcd don't have any backlight.


// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);

Proteus simulation of arduino uno
Simulation in proteus
Hope, you had enjoyed the tutorial.

Stay tuned for more updates !!

How to add library to proteus

In this post, we are going to discuss how to place library in proteus. As we all know that, there is no library of many components/ devices in arduino. We can add external libraries to proteus either provided by third party or written by an individual.

Basically, library consists of two files having extension .IDX and .LIB

We have to place these two files in the following directory:

C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\LIBRARY

If you are using 32-bit windows, then you to place  file in Program Files. As there is no Program Files(x86) in 32-bit windows.

Download arduino library from the link given below:

Download from here:

Now extract this rar file. You have to place only arduino.idx and arduino.lib in library folder.

how to add library in proteus

Check this video:

Hope, you had enjoyed the tutorial.

Stay tuned for more updates..