0% found this document useful (1 vote)
3K views14 pages

LED Blinking With 8051 Microcontroller Using Keil C

This document describes a project to blink an LED connected to an 8051 microcontroller using Keil C. It defines port 2 as the output port connected to the LED and port 3 as the input port. The code uses delays to blink the LED by turning the output on and off. It was written in C using the Keil software and the hex file was loaded onto the microcontroller.

Uploaded by

Aditi Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
3K views14 pages

LED Blinking With 8051 Microcontroller Using Keil C

This document describes a project to blink an LED connected to an 8051 microcontroller using Keil C. It defines port 2 as the output port connected to the LED and port 3 as the input port. The code uses delays to blink the LED by turning the output on and off. It was written in C using the Keil software and the hex file was loaded onto the microcontroller.

Uploaded by

Aditi Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

LED Blinking with 8051 Microcontroller using Keil C – AT89C51

A Project Report
Submitted in partial fulfillment of the requirement of

University of Mumbai
For the Degree of

Bachelor of Engineering
(Electronics and Telecommunication Engineering)
By

Anjali Sutar (Roll No.127),


Madhuri Nikam (Roll No.125),
Aditi Jadhav (Roll No.112),
Ashwini Bambale (Roll No.103).

Under the guidance of

Mrs. MANISHA HATKAR

Department of Electronics and Telecommunication Engineering


Smt.Indira Gandhi College of Engineering,
Sector 8, Ghansoli, Navi Mumbai
(Affiliated to University of Mumbai)

1|Page
Smt. Indira Gandhi College of Engineering

(Affiliated to the University of Mumbai)

Sector 8, Ghansoli, Navi Mumbai 400 701.


CERTIFICATE

This to certify that synopsis on Project entitled

“LED Blinking using 8051 Microcontroller and KeiL C – AT89C51”

submitted by
Anjali Sutar (Roll No.127),
Madhuri Nikam (Roll No.125),
Aditi Jadhav (Roll No.112),
Ashwini Bambale (Roll No.103).

is approved for the degree of

Bachelor of Engineering
In
Electronics and Telecommunication Engineering.

Guide Examiner

Head of Department principal

2|Page
ACKNOWLEDGMENTS
We would like to express our sincere thanks and gratitude to Smt. Indira Gandhi
College of Engineering and the Principal for having project, for giving the participants
and opportunity to integrate the learning from this graduate course. 

Special regards and thanks to our guide Mrs. Manisha Hatkar for her valuable
guidance, support and encouragement for carrying out this project work and
helping us in the development of designed algorithm and practical insights in
application of the various theoretical frameworks. 

We would also like to thank head of Electronics and Telecommunication department


Prof.V.P. Patil and faculty members for giving us this opportunity and guidance and
encouragement. 

Should there be any shortcomings in this work, they are because of human limitations
in application of knowledge. We would be grateful if there are brought to my notice, so
that we can learn and improve. 

3|Page
ABSTRACT

We are going to blink an led with 8051 connected to


pin0 of 89c51 microcontroller. Input to the
microcontroller can be given through push button and
output can be seen through LED. Firstly, all the port
pins are defined. Port 2 is used as output port and port
3 is used as input port.  These Ports are initialized with
0 (to write) and 1 (to read) logic respectively. Delay
function is used to give the delay in showing output.
Frequency of crystal should be set to 11.059MHz.
Program is written in C language using “keil” software
and hex file is loaded in the microcontroller.

4|Page
CONTENT 

1) INTRODUCTION………………………………………..(6)
2) 8051 PORTS………………………………………………(6)
3) CIRCUIT DIAGRAM…………………………………….(7)
4) SOURCE CODE…………………………………………..(8)
5) CODE EXPLAINATION…………………………………(8)
6) OUTPUT……………………………………………………..(10)
7) APPLICATION………………………………………………(14)
8) CONCLUSION……………………………………………(14)

5|Page
INTRODUCTION:

8051 Microcontroller is a programmable device which is used for controlling purpose.


Basically 8051 controllers are Mask programmable means it will programmed at the
time of manufacturing and will not programmed again, there is a derivative of 8051
microcontroller, 89c51 micro controller which is re-programmable.

AT89C51

89c51 is 8-bit device means it is capable of doing 8-bit operations.  It has 4 ports which
are used as input or output according to your need.
This device also has Timer, Serial Port interface and Interrupt controlling you can use
these according to your need.

8051 PORTS:

6|Page
Circuit Diagram:

LED
Blinking with 8051 Microcontroller – AT89C51

SOURCE CODE:

7|Page
#include<reg52.h> // special function register declarations
// for the intended 8051 derivative

sbit LED = P2^0; // Defining LED pin

void Delay(void); // Function prototype declaration

void main (void)


{
while(1) // infinite loop
{
LED = 0; // LED ON
Delay();
LED = 1; // LED OFF
Delay();
}
}

void Delay(void)
{
int j;
int i;
for(i=0;i<10;i++)
{
for(j=0;j<10000;j++)
{
}
}
}

Code Explanation:
8|Page
Anything written after // lines considered to be comment. And anything written in comment is not compiled. This
commenting will help programmer to make their program more readable to others. Also, comments are useful
to quickly revised meaning of particular line of code.
#include<reg51.h>
This include statement add header file for the registers and SFRs (Special Function Registers) of 8051. This is
standard header file for 8051 MCU. Which contain definitions of all registers of 8051 Microcontroller.
sbit LED=P1^0
sbit data type is useful to access single bit addressable register. It allows access to single bits of SFR (special
function registers). Some of SFRs are bit addressable. We can use sbit to access individual bits of the port. As
we have accessed P1.0 Pin by name LED.
void Delay()
{
int i=0,j=0;
for(i=0;i<100;i++)
{
for(j=0;j<1000;j++);
}
}
This Delay function used to generate delay between turning LED ON and OFF continuously. In this loop first
we initialized variable i and j equals to zero then we can say that for each i value inner loop for(j=0;j<1000;j+
+); runs for 1000 machine cycles. Means we can conclude that function Delay() runs
for 100X1000=100000 machine cycles. Means this loop keeps controller busy for 1 lack machine cycle and
during this period our controller does not perform any other task.
void main ()
Our program execution starts from here.

OUTPUT:

9|Page
10 | P a g e
11 | P a g e
12 | P a g e
AT89C51 needs an oscillator for its clock generation, so we should connect external
oscillator. Two 22pF capacitors are used to stabilize the operation of the Crystal
Oscillator. EA should be strapped to VCC for internal program executions. AT89C51
has no internal Power On Reset, so we have to do it externally through the RST pin
using Capacitor and Resistor. When the power is switched ON, voltage across
capacitor will be zero, thus voltage across resistor will be 5V and reset occurs. As
the capacitor charges voltage across the resistor gradually reduces to zero.

13 | P a g e
APPLICATION:

 The NXP PCA9550, PCA9551, PCA9552, and PCA9553 are used to blink LEDs
in I2C-bus and SMBus applications. Each LED can be on, off, or flashing at one
of two programmable rates without overloading the I 2C-bus or tying up the I2C-
bus master.The blink rate can vary from 0.025 to 6.4 seconds (40 to 0.156 Hz) in
256 steps. The duty cycle is programmable in 256 steps, for flexible on and off
times. There can be a short flash of light, for example, or long on periods with a
very short off period.Any bits that aren’t used to control LEDs can be used as
general-purpose I/O (GPIO), for a quick, easy to add sensors, push-buttons,
alarm monitors, LEDs, fans, and more.On the PCA9551 and PCA9552, three
hardware pins (A0, A1, A2) let up to eight identical devices share the same
I2C/SMBus. On the PCA9550, a single hardware pin (A0), supports up to two
devices on the same I2C/SMBus. Due to hardware pin limitations, the PCA9553
doesn’t have address pins so the address is fixed.

CONCLUSION:
 LED blinking is the most basic project with a microcontroller to see a physical
output. One can understand the concept of input-output configurations of the
general-purpose I/O port in a microcontroller with the simple LED blinking project.
The LEDs are simple electronic display units available. This tutorial will explain
the method of interfacing LED with 8051 microcontrollers and to develop a c
code for blinking the same.

14 | P a g e

You might also like