LED Blinking With 8051 Microcontroller Using Keil C
LED Blinking With 8051 Microcontroller Using Keil C
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
1|Page
Smt. Indira Gandhi College of Engineering
submitted by
Anjali Sutar (Roll No.127),
Madhuri Nikam (Roll No.125),
Aditi Jadhav (Roll No.112),
Ashwini Bambale (Roll No.103).
Bachelor of Engineering
In
Electronics and Telecommunication Engineering.
Guide Examiner
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.
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
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:
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
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