How to create HEX file in keil for 8051 microcontroller

How to create and burn HEX file for 8051 microcontroller in keil:

Hello friends, today I am going to tell you how to create a microcontroller program file (.HEX format) and how to burn HEX program file in our 8051 microcontroller for any desired project.

Let me tell you one thing in this tutorial I am not going to learn you ‘C’ program, I am just telling you how to create and burn .hex program file in  a 8051 microcontroller (assuming that you have c program with you).

For programming a microcontroller we are going to use one of the best microcontroller programming software called “Keil”. Using this software you can compile your ‘C’ program and can check is their any errors in your program or not. After removing all errors (if any), you can create program file also known as .hex file which we are going to use for our microcontroller programming.

So let us learn – How to create a hex file for 8051 microcontroller using Keil software step by step:

(Before proceeding to our main tutorial make sure that you have your c program file (.c format or in word document), which we are going to convert into .hex file using ‘Keil’ software)

Step 1: Download ‘Keil uVision3’: Click here to download keil uVision software. (After downloading install it in your computer).

Step 2: Open the Keil software, you will see following window.

Keil tutorial for programming a microcontroller 1
Keil tutorial for programming a microcontroller 1

Step 3: Now be ready for your first microcontroller project using keil software. Now we are going to do our new project, this can be done by by using following steps:

  • Click on ‘Project’ then ‘New project’. A new window will appear on the screen (Create new project). Simply type your project name (in my case it is ‘my first keil project’) and click ‘Save’.

    Keil tutorial for programming a microcontroller 2
    Keil tutorial for programming a microcontroller 2
  • When you click on save button, a new window will appear (Select Device for Target ‘Target 1’) here we are required to tell – which microcontroller we are going to use? (For example, if we are using famous 8051 family or AT89C51, then double click on ‘Atmel’ here you will see all the microcontrollers made by ‘Atmel’. Click on any one (in my case it is AT89C51) which you are going to program). Then click on OK.

    Keil tutorial for programming a microcontroller 3
    Keil tutorial for programming a microcontroller 3
  • After that another window will appear asking for “Copy Standard 8051 Startup Code to Project Folder and Add File to Project?” Click on ‘yes’.

    Keil tutorial for programming a microcontroller 4
    Keil tutorial for programming a microcontroller 4

If you observe ‘Project workspace’ which is located at the left side, you will see ‘STARTUP.A51’ file is their. It means it is the file which contains the assembly language commands of 8051 microcontroller.

Step 4: Now we are required to configure option value of our microcontroller project. For doing this click on ‘Project’ then “Option for Target ‘Target 1’”.

  • Select Tab of Target to configure value of MCU Target as : Configure X-TAL to be 12 MHz (which is initially 24 MHz)

    Keil tutorial for programming a microcontroller 5
    Keil tutorial for programming a microcontroller 5
  • Select Tab of Output and click on checkbox of “Create HEX file”. Click OK.

    Keil tutorial for programming a microcontroller 6
    Keil tutorial for programming a microcontroller 6

Step 5: Now we are ready for writing a first C program.

  • Click on ‘File’ and then click on ‘New’. A new window will appear in which we are going to write our C program. If you already have, simply paste it in this window. After completing your C program click on ‘File’ and then ‘Save’ (Shortcut ‘Ctrl+S’) . We are required to save this file with extension ‘.c’ Don’t forgot to write .c after name of c program. Figure is shown below:
  • Add Files into Project File, click command Project ? Components, Environment, Books…, select Tab Project Components and then select desired Add File to add into Project File.

    Keil tutorial for programming a microcontroller 8
    Keil tutorial for programming a microcontroller 8
  • In the first time, we must select Files of type to be “C Source files (*.c)” and it will display Files name that is C Language Source Code. Click icon of File named “my first keil project.c” and then click Add then close then OK.
  • Now if there is ‘my first keil project.c’ file present in the Project workspace which is at upper left of the screen, you are on your way!

Step 6: Now this is our last step of this tutorial. Here in the last step we are going to check is everything is fine without errors or not. We are checking our c program and converting it into hex file. So for doing this click on ‘Project’ and then click on ‘Rebuild all target files’ (There is also shortcut for this command on upper left). So when you click on this button you will see that your program is being compiled. If there is massage like “my first keil project” – 0 Error(s), 0 Warning(s)”. it means you have not any errors in your program and you can use its HEX file for your microcontroller.

Keil tutorial for programming a microcontroller 9
Keil tutorial for programming a microcontroller 9

Now close the software and open the directory where you save your project. Generally it is in (C:KeilC51Examples……). So there is one file containing .hex format this is your program file. You can burn this program in your microcontroller using microcontroller kit.

tags: how to program a 8051 microcontroller. how to write a program for 8051 microcontroller. keil – microcontroller programming software. step by step tutorial for programming a microcontroller. How to burn program in a 8051 microcontroller. How to create hex file in keil software for 8051 microcontroller.

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Interfacing 433MHz RF Modules with 8051 Microcontroller

Hello Friends Today I am going to show you how to use a 433MHz RF module in your 8051 Projects. The 433MHz RF module is one of the cheapest ways of wireless communication other than IR that you can use in your 8051 projects.There is receiving and Transmitting module that we will needed. You can easily find them online for3-4$(150-200 Indian Rs).

Components required

  • Microcontroller (P89V51RD2) (2)
  • Resistor 10K (1)
  • Capacitor 33pF (2)
  • Capacitor 10uF (1)
  • 11.0592MHz Crystal (1)
  • 433MHz RF Transmitter (1)
  • 433MHz RF Receiver (1)
  • Buzzer(optional) (1)

Circuit Diagram and Description

RF Transmitter-receiver

Receiving circuit
Receiving circuit

Transmitting Circuit
Transmitting Circuit

Connections of the Transmitter Module

The smaller module of the two with a crystal on it is the Transmitter module. The Pin connections for the module are as below

Pin on Module            Connection

GND               GND on 8051 Board

DATA             P3.1 on 8051 Board

Vcc                  Vcc on 8051 Board

ANT                Connected to 17.25cm long wire

Connections for the Receiver Module

The Larger module of the two is the Receiver module.The Module has multiple GND and Vcc pins which need to be connected externally. The Pin connections for the module are as below

Pin on Module            Connection

GND              GND on 8051 Board

DATA            P3.0 on 8051 Board

Vcc                 Vcc on 8051 Board

ANT               Connected to 17.25cm long wire

About the Program

In this particular program, we are using UART to transmit 8-bit data over the RF module. The data pin of the transmit module is connected to the transmit pin of the 8051. When the Switch 4 is pressed on the 8051 Board then the ASCII value of character t is sent over the RFmodule.If this is received at the receiving 8051 then the Buzzer will turn on for 5 Seconds.

Download

Click here to download the C, Assembly and Hex file.

This article is written by Aditya Wani.

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Accidental Vehicle Lifting Robot – Electronics Mini Project

Nowadays the number of road accidents increasing frequently. Whenever vehicle accident occurs on the road there may be a high possibility of traffic. In such cases, if we could able to move that accidental vehicle from the road, we can easily avoid the traffic. To make this possible we can build an accidental vehicle lifting robot using the embedded system. You can build its prototype using a small vehicle which you can easily found in the toy store.

Accidental Vehicle Lifting Robot

Accidental Vehicle Lifting Robot
Accidental Vehicle Lifting Robot

 

Working of Accidental Vehicle Lifting Robot

The working of this project is based on the microcontroller which is connected to a motor to move the accidental vehicle. Also, the microcontroller is connected to a chain based rod to lift the vehicle.

The complete circuitry of this project contains microcontroller board which has a robotic platform, keypad, electric motors to move the vehicles and lifting the chain based rod. These motors will be moved accordingly to the instruction given through keys connected to the microcontroller.

Components required

Hardware:

  • AT89c52
  • Robot platform
  • Driver circuit
  • Motor for lifting
  • Controlling keys
  • 12 v battery

Software:

  • Embedded ‘C’
  • RIDE/KEIL to write code
  • ISP to burn the chip

Advantages Accidental Vehicle Lifting Robot:

  • Low cost
  • automated operation
  • Low Power consumption

I hope you liked this project idea. Please like our facebook page and subscribe to our newsletter for upcoming projects. If you have any queries feel free to ask in the comment section below. Have a nice day!

Sending SMS from No Signal Area – Electronics Mini Project

Hi friends, in previous article we have seen Zigbee and GPS project which tracks a vehicle. Today we will build another innovative electronic project which will send a SMS from No Signal Area. There are many locations where we get poor range or completely no range. So using this embedded system we can send a SMS from such locations. The only condition we need here is, we should have a mobile network at the receiving end of Zigbee module.

This is low cost project and highly innovative. You can build such projects for your final year engineering submissions also.

Sending SMS from No Signal Area

Objective

The main objective of this micocontroller project is to send a SMS from No Signal area which is also known as Black Spot area using Zigbee and GSM module.

Components:

Hardware

  1. 8051 family development board
  2. power Supply
  3. Zigbee modules
  4. GSM modem.
  5. Max232

Software

  1. Embedded ‘C’
  2. RIDE to write code
  3. ISP to burn the chip

Block Diagrams

Zigbee Transmitter Block Diagram

Sending SMS from No Signal Area Transmitter Block Diagram

Zigbee Receiver Block Diagram

Sending SMS from No Signal Area Receiver Block Diagram

Power Supply:

Power Supply

Description

As already stated, this project is useful for creating signal, using GSM module we can send SMS through that signal to destination. In this project we are using two different frequencies. Zigbee has frequency 2.4GHz and GSM has frequency 1800 MHz.

Main circuitry of this project contains two embedded development boards. One contain Zigbee and Keypad and other contain Zigbee and GSM. We need to place first board in No signal (Black spot) area. Other development board which contains Zigbee receiver and GSM module is kept in area where there is mobile network.

When you type a message using keyboard and hit enter from No signal area, Zigbee transmitter will send a signal with message to the receiver end. Receiver end of Zigbee also has GSM module which will send that SMS to destination mobile.

Watch this Video

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Vehicle Tracking Using Microcontroller & GPS Module: Electronics Project

Hi friends, In this project, we are going to make a Vehicle tracking system using 8051 microcontroller and GPS module. You can use this project for you final year submissions which cost you around 2500Rs. This is quite interesting and useful project in our day to day life.

We can easily track lost vehicle using this Vehicle tracking GPS module. In this project we are using 8051 microcontroller, GPS module to track the vehicle location. This system will send a location of the vehicle in the form of longitude and latitude values. If you enhance this project you can also easily track the position of the vehicle in the graphical presentation on your PC.

Vehicle Tracking Using Microcontroller and GPS Module

Objective

The main objective behind developing this project is to track the vehicle position using microcontroller GPS module & Zigbee module along with software to see the track of vehicle on PC.

Block Diagrams

1) Connecting GPS with ZigBee:

Connecting GPS and Zigbee
Connecting GPS and Zigbee

 

2) Vehicle Tracking Block Diagram:

Vehicle Tracking Block Diagram
Vehicle Tracking Block Diagram

 

3) Power supply for Vehicle Tracking Circuit:

Power Supply
Power Supply

 

Description

In this project, we using AVL technology. AVL stands for Automatic Vehicle Location. AVL is an advanced method to track and monitor any vehicle which is connected with Vehicle tracking circuit.AVL is a combination of GPS (Global Positioning System) and GIS (Geographic Information System). All data transmission in this project depends on GPS satellite and receiver on the board and Zigbee.

There are plenty of tutorials available on the Internet on how to connect Zigbee with your GPS module. Once you integrate Zigbee and GPS connect your circuit with Microcontroller. You can refer this article on how to connect GPS with 8051 microcontroller.

Software

For building this Vehicle tracking system you will need Embedded C knowledge, RIDE to write code and ISP to burn the chip.

Hardware

  • 8051 microcontroller kit
  • power supply
  • Zigbee module
  • GPS module

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Wi-Fi Based Industrial Automation – Electronics Mini Project

Hi friends, in this project we will see How to automate industrial equipment using Wi-Fi network. We are going to operate electrical equipment from the central control point. This is low cost and flexible mini project which you can use for your final year project. It is also secured industrial automation system.

Components Required

  1. Rabbits Processor – RCM5600W
  2. RS 232 cable
  3. PC
  4. Industrial equipment to be controlled using Wi-Fi network

Block diagram

Receiving:

Block diagram for Industrial automation
Block diagram for Industrial automation

 

Transmission:

transmission
Transmission

Description

In this automation system, devices to be operated are connected to the Rabbit’s processor. You can see devices like Fan, Heater, and the electric bulb is connected through the Realy circuit. Please read Data sheet of Rabbits Processor for details. The current status (on, off) of the device is sent to the web page which is accessed by the end user. For this, you need a PC which is connected to the Rabbits Processors Wi-Fi network.

When the end user sends an action for operating any device, it will be received by Rabbits Processor and get executed. In this way, automation of industrial equipment will take place using Wi-Fi.

Industrial automation
Industrial automation
Source: RCM5600W Datasheet (http://www.digi.com/pdf/ds_rcm5600w.pdf)

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Temperature Indicator using PIC Microcontroller: Electronics Project

Hi friends, today we will see how to make temperature indicator using PIC microcontroller. The basic aim of this project is to make you familiar with PIC microcontroller. It also explains how LM35 and 7 segment displays can be interfaced with PIC microcontroller.

Components required

Following is a list of components required for temperature indicator using PIC microcontroller – mini project:

  • PIC microcontroller (PIC16F676)
  • 4 digit (or 3digit) seven segment display (Common cathode)
  • Temperature sensor (LM35) IC
  • 5V DC power supply

Circuit diagram

The following figure shows a circuit diagram of temperature indicator using PIC microcontroller.

Temperature Indicator Using Microcontroller
Temperature Indicator Using Microcontroller

Theory

In this mini project, we have used PIC microcontroller and a four digit seven segment display is interfaced with it. For sensing the surrounding temperature we have used a temperature sensing IC i.e. LM35. You can use a voltmeter to crosscheck whether the indicator giving correct output or not. The output of the temperature in terms of volts will be in the range of mV.

Working of LM35

LM35 is an integrated temperature sensor. It produces an output voltage proportional to the temperature. The advantage of using LM35 is that it does not require any external calibration technique and it has an accuracy of ±0.4 degree Celsius at room temperature. It draws the only 60µA from supply and possesses low self-heating. Thus the chances of error get minimized.

Download

Click here to download the project content. It consists of C program, Proteus design, HEX file for PIC microcontroller and circuit diagram.

You may also like

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Digital Clock using 8051 Microcontroller & LCD display – Mini Project

Hello friends, today we are going to make a simple digital clock using 8051 microcontrollers which you can make as your engineering mini-project. In this mini project, we are using one 8051 families based microcontroller, one 16×2 LCD display and one 4×4 keyboard for settling the time.

Components required

For making a simple digital clock using microcontroller you will require following components:

Sr. no. Component Quantity
1 Microcontroller (P89V51RD2) 1
2 LCD display (16×2) 1
3 4×4 keyboard 1
4 Resistor 10K 1
5 Capacitor 33pF 2
6 Capacitor 10uF 1
7 12MHz Crystal 1

Circuit diagram

A circuit diagram for simple digital clock using 8051 microcontrollers is shown below:

digital clock using 8051 microcontroller and LCD display
Digital clock using 8051 microcontroller and LCD display

Circuit building

Connect the 4×4 keypad with port 1 of the microcontroller. Connect 16×2 LCD display with port 2 of the microcontroller (make sure that all the data pins of LCD display are connected to the microcontroller correctly). The rs (register set) pin of  LCD is connected to pin 3.5 (pin number: 15) and en (enable) pin is connected to pin 3.6 (pin number 16) of the microcontroller. Connect crystal to pin 18 and 19 of the microcontroller. We are using 12MHz frequency Crystal. For reset, circuitry connects a pushbutton to pin 9 of the microcontroller. We can also use a potentiometer to adjust the contrast of LCD.

Pin description of LCD display

lcd pin diagram

Pin number Name Description
1 Vss Ground
2 Vdd +5V
3 Vee Contrast Adjustment -2V to -5V
4 RS Register Select
5 RW 1 -Read, 0-Write
6 E Enable Strobe
7 D0 Data Line
8 D1 Data Line
9 D2 Data Line
10 D3 Data Line
11 D4 Data Line
12 D5 Data Line
13 D6 Data Line
14 D7 Data Line
15 LED+ Backlit LED +V Vdd (Optional signal)
16 LED- Backlit LED +V Vdd (Optional signal)

Download

Click here to download C program and HEX file for this mini project.

You may also like

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Digital Thermometer using 8051 Microcontroller: Electronics Mini Project

Today we are going to make a simple mini-project using 8051 microcontrollers. A digital thermometer using 8051 microcontrollers. A thermometer is a device that measures temperature or temperature gradient using a variety of different principles. Let us see how to make Digital Thermometer using 8051 microcontrollers.

Components required

  • 8051 microcontroller (like AT89c51, 89C51RD2, etc.)
  • ADC0804
  • LM35 temperature sensor
  • Resistors, Potentiometer, etc.

Circuit diagram

Digital Thermometer using 8051 Microcontroller
Digital Thermometer using 8051 Microcontroller

Working of Digital Thermometer

The output of digital thermometer is in Celsius scale. To display the output i.e. the temperature we have used a 16*2 LCD display. LM 35 is temperature sensor IC which is used to sense the temperature. Normally LM35 generates a 10mV change in output voltage per degree celsius change in temperature. This temperature is then converted into Celcius scale using analog to digital converter i.e. ADC0804.

LM 35 Temperature sensor:

LM 35 Pin diagram
LM 35 Pin diagram

Specifications of LM 35 temperature sensor IC are as follows

  • The accuracy of LM35 is +-0.5 degree celsius.
  • Its temperature range is from -55 to 150-degree celsius.
  • Sensor gain = 10 (mV/Deg C)
  • Output impedance = 0.4 Ohm
  • Supply Voltage (Min) = 4V
  • Supply voltage (Max) = 30V

Applications of Digital Thermometer

  1. Thermometers are used in a wide variety of scientific and engineering applications, especially measurement systems.
  2. Digital thermometers can be used in roadways in cold weather climates to check if icing condition exists or not.

Download

Click here to download C program and Proteus simulation files.

You may also like

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

Digital Stopwatch using 8051 Microcontroller: Electronics Project

In this mini-project, we are going to make a simple Digital Stopwatch by using a Microcontroller from 8051 families. Digital Stopwatch allows you to record the exact number of hours and minutes you worked on a task/activity. It is a special type of watch with buttons that start, stop, and then zero the hands, used to time races.

Components required

  • 8051 Microcontroller (89C51)
  • Resistor – 10K
  • Capacitor – 10uF, 33pF (two)
  • Crystal oscillator – 12MHz
  • LCD display.

Circuit diagram

Digital Stopwatch using 8051 Microcontroller
Digital Stopwatch using 8051 Microcontroller

Pin description of LCD display

lcd pin diagram
LCD pin diagram
Pinnumber Name Description
1 Vss Ground
2 Vdd +5V
3 Vee Contrast Adjustment -2V to -5V
4 RS Register Select
5 RW 1 -Read, 0-Write
6 E Enable Strobe
7 D0 Data Line
8 D1 Data Line
9 D2 Data Line
10 D3 Data Line
11 D4 Data Line
12 D5 Data Line
13 D6 Data Line
14 D7 Data Line
15 LED+ Backlit LED +V Vdd (Optional signal)
16 LED- Backlit LED +V Vdd (Optional signal)

C program

// ************************************************
// Project:   Digital Stopwatch using 8051 microcontroller
// Author:    Mayuresh Joshi
// Blog: myclassbook.org
// ************************************************
#include<reg51.h>
//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void WriteCommandToLCD(int);
void WriteDataToLCD(char);
void ClearLCDScreen(void);
void InitTimer0(void);
void UpdateTimeCounters(void);
void DisplayTimeToLCD(unsigned int,unsigned int,unsigned int);
//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************
// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;
// Define Clock variables
unsigned int usecCounter = 0;
unsigned int msCounter   = 0;
unsigned int secCounter  = 0;
unsigned int minCounter  = 0;
unsigned int hrCounter   = 0;
// ***********************************************************
// Main program
//
void main(void)
{
cct_init();             // Make all ports zero
lcdinit();              // Initilize LCD
InitTimer0();           // Start Timer0
while(1)
{
if( msCounter == 0 )                                       // msCounter becomes zero after exact one sec
{
DisplayTimeToLCD(hrCounter, minCounter, secCounter);   // Displays time in HH:MM:SS format
}
UpdateTimeCounters();                                      // Update sec, min, hours counters
}
}
void cct_init(void)
{
P0 = 0x00;   //not used
P1 = 0x00;   //not used
P2 = 0x00;   //used as data port
P3 = 0x00;   //used for generating E and RS
}
void InitTimer0(void)
{
TMOD &= 0xF0;    // Clear 4bit field for timer0
TMOD |= 0x02;    // Set timer0 in mode 2
TH0 = 0x05;      // 250 usec reloading time
TL0 = 0x05;      // First time value
ET0 = 1;         // Enable Timer0 interrupts
EA  = 1;         // Global interrupt enable
TR0 = 1;         // Start Timer 0
}
void Timer0_ISR (void) interrupt 1     // It is called after every 250usec
{
usecCounter = usecCounter + 250;   // Count 250 usec
if(usecCounter==1000)              // 1000 usec means 1msec
{
msCounter++;
usecCounter = 0;
}
TF0 = 0;     // Clear the interrupt flag
}
void UpdateTimeCounters(void)
{
if (msCounter==1000)
{
secCounter++;
msCounter=0;
}
if(secCounter==60)
{
minCounter++;
secCounter=0;
}
if(minCounter==60)
{
hrCounter++;
minCounter=0;
}
if(hrCounter==24)
{
hrCounter = 0;
}
}
void DisplayTimeToLCD( unsigned int h, unsigned int m, unsigned int s )   // Displays time in HH:MM:SS format
{
ClearLCDScreen();      // Move cursor to zero location and clear screen
// Display Hour
WriteDataToLCD( (h/10)+0x30 );
WriteDataToLCD( (h%10)+0x30 );
//Display ':'
WriteDataToLCD(':');
//Display Minutes
WriteDataToLCD( (m/10)+0x30 );
WriteDataToLCD( (m%10)+0x30 );
//Display ':'
WriteDataToLCD(':');
//Display Seconds
WriteDataToLCD( (s/10)+0x30 );
WriteDataToLCD( (s%10)+0x30 );
}
void delay(int a)
{
int i;
for(i=0;i<a;i++);   //null statement
}
void WriteDataToLCD(char t)
{
RS = 1;             // This is data
P2 &= 0x0F;                         // Make P2.4 to P2.7 zero
P2 |= (t&0xF0);     // Write Upper nibble of data
E  = 1;             // => E = 1
delay(150);
E  = 0;             // => E = 0
delay(150);
P2 &= 0x0F;                         // Make P2.4 to P2.7 zero
P2 |= ((t<<4)&0xF0);// Write Lower nibble of data
E  = 1;             // => E = 1
delay(150);
E  = 0;             // => E = 0
delay(150);
}
void WriteCommandToLCD(int z)
{
RS = 0;             // This is command
P2 &= 0x0F;                         // Make P2.4 to P2.7 zero
P2 |= (z&0xF0);     // Write Upper nibble of data
E  = 1;             // => E = 1
delay(150);
E  = 0;             // => E = 0
delay(150);
P2 &= 0x0F;                         // Make P2.4 to P2.7 zero
P2 |= ((z<<4)&0xF0);// Write Lower nibble of data
E  = 1;             // => E = 1
delay(150);
E  = 0;             // => E = 0
delay(150);
}
void lcdinit(void)
{
///////////// Reset process from datasheet /////////
delay(15000);
P2 &= 0x0F;                           // Make P2.4 to P2.7 zero
P2 |= (0x30&0xF0);    // Write 0x3
E  = 1;               // => E = 1
delay(150);
E  = 0;               // => E = 0
delay(150);
delay(4500);
P2 &= 0x0F;                           // Make P2.4 to P2.7 zero
P2 |= (0x30&0xF0);    // Write 0x3
E  = 1;               // => E = 1
delay(150);
E  = 0;               // => E = 0
delay(150);
delay(300);
P2 &= 0x0F;                           // Make P2.4 to P2.7 zero
P2 |= (0x30&0xF0);    // Write 0x3
E  = 1;               // => E = 1
delay(150);
E  = 0;               // => E = 0
delay(150);
delay(650);
P2 &= 0x0F;                           // Make P2.4 to P2.7 zero
P2 |= (0x20&0xF0);    // Write 0x2
E  = 1;               // => E = 1
delay(150);
E  = 0;               // => E = 0
delay(150);
delay(650);
/////////////////////////////////////////////////////
WriteCommandToLCD(0x28);    //function set
WriteCommandToLCD(0x0c);    //display on,cursor off,blink off
WriteCommandToLCD(0x01);    //clear display
WriteCommandToLCD(0x06);    //entry mode, set increment
}
void ClearLCDScreen(void)
{
WriteCommandToLCD(0x01);   // Clear screen command
delay(1000);
}

Download

Click here to download C program, Proteus simulation file, HEX file, etc.

You may also like

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!