8051 code of led blinking using delay
This blog is also for the persons who wants to become a firmware developer. For the beginner's i am posting my first code of Led blinking using delay for 8051 micro-controller.
For developing code for Atmel 8051 series you required Keil u vision software. which you can download from keil's website. if you wants to see the result without hardware you can use simulation software proteus developed by labcenter Electronics.you can also download its demo version from their website.
In this code Led is connected to Pin 21 of micro-controller which is P2.0 .Now here you can see in code i have added a header files.one is "#include<REGX51.h>" which is necessary for 8051 uC .the second is "delay.h" which has been created by me in which i defined macros and function.
In main function firstly i put Port 2 low because the port is internally pulled up except port 0.for reference you can see atmel 89c51 datasheet.
when we entered in while loop (infinite) i pull the pin 21 high and generate 500 milisec delay by using Delay_msec function (which is shown in below image) after that i again put PIN 21 Low and generate 500 mili second delay again.
In this manner we can blink a led with 500 mili second delay.
In above code "LED", HIGH & LOW is macros which are defined in delay.h file.shown in imagegiven below:-
Delay function through which i have generate delay is defined in delay.c. also shown in image below:-
No comments:
Post a Comment