Вы находитесь на странице: 1из 7

PRACTICAL NO:2

Aim: Write a program to blink an LED.

Components:

 CAP
 CRYSTAL
 LED-BIBY
 RESISTOR

Design:

Component values:
Crystal -> Frequency = 11.059mhz
Cap -> Capacitance = 33p
Resistor -> Resistance (ohm)=100
Code:
# include <regx51.h>
void delay_ms(unsigned int k)
{
unsigned int i,j;
for (i=0;i<k;i++)
{
for (j=0;j<110;j++)
{
}
}
}
void main ()
{
while(1)
{
P1=0XDB;
while(1)
{
delay_ms(3);
P1=~P1 ;
delay_ms(3);
P1=~P1;
}
}
}

STEPS:

Go to Keil uVision4 and create a new project.


Select Atmel and then AT89C51.
Right click on the Source Group 1 and select “ Add Files to Group Source Group 1”.

Select the file that has been created. “ blinking led.c”

Go the Project -> Options for Target Target 1.


In the Target tab, change the Xtal(mhz):11.059

In the Output tab, Select the “create HEX file” option

Go to Debug option and start debugging


Go to Peripherals and select the Port 1 and press F5 to run the code.

Output:
In the design page, right click on the micro controller and select “Edit properties”.

In the program file option, browse and add the hex file of the code. “blinking led.hex”
Run the design.

Вам также может понравиться