1 second delay with 8051 microcontroller – Diy project
8051 microcontroller one second delay -Project code
Coming to main function. Statement P1=0x00 is initializing Port-1 as Output. Then led=1 is making our led to glow. delay() function is something that is the topic of this tutorial. led=0 is switching off our led after 1 second. This means led will glow for 1 second and then turn off for 1 second. Whole of this part is placed in while(1) loop making the Statements to execute for ever.
The main thing in the code is delay() function & how is it working? To understand it you should know about the internal timer registers and i hope you take the tutorial mentioned above. You can calculate the values for TH and TL registers by using the formula given in the tutorial. Also you will be able to know about the TMOD(Timer Mode) register bits. If you don’t go through the lesson then hurry up and take it
Now if you took the tutorial you are thinking what’s going on in delay() function. Actually i calculated the delay values for 2 ms and loaded the calculated values for TH and TL registers in them.
Circuit diagram of the project is given below.
I further generated one minute delay on the same principle listed above. You can also check out the project below. Source code of the project is also open source.
Filed Under: 8051 Microcontroller, Microcontroller Projects