01. BLINKING A LED USING 8051
Fundamentals Switching is the best start for the field of Embedded Systems . It Ensures the Concepts of Programming 8051 Microconttroller in 'C' Language , and analyzing the Features of 8051 Microcontroller. such that PORT's and their Roles. 1st let's start with Blinking an LED.
We know the working of simple LED (Light Emitting Diode). It will glow only at Forward Bias i.e by supplying + ve to Anode and Gnd to Cathode. shown in Below Fig.
Let us Interface this to 8051 Microcontroller, below fig. will show the interfacing of 8051 with a LED.
I Used AT89C52 Microcontroller from ATMEL family of 8051 in all of my Tutorials.
We've Done with the Interfacing , We've to look after the Programming Part. Before that we should glance some of the feature of 8051 . In 8051 we've 4 PORT's viz. PORT0,PORT1,PORT2,PORT3 and each Ports consisting of 8 Input or Output Pins for eg. PORT0 has (P0.0 --- P0.7) totally 8 pins.
In the Same way for PORT 2 we've 8 Input / Output Pins. In That we've Connected LED to P2.0 .
For the CODING ,
We've to Write Related Hexadecimal value on the CODES.
#include<reg52.h>
#include<stdio.h>
void delay(unsigned int value);
void main()
{
while(1)
{
P2=0x01;
delay(150);
P2=0x00;
delay(150);
}
}
void delay(unsigned int value)
{
unsigned int x,y;
{
for(x=0;x<1000;x++)
for(y=0;y<value;y++);
}
}
For Detailed Tutorial Watch Video .
No comments:
Post a Comment