/* In Microcontroller programming if you want to generate a normal delay then you can generate using for loop also.
Here i m gonna write a program to toggle a bit of port P0 of microcontroller using delay.
*/
#include<Reg51.h>
sbit MyBit = PO^1 ;
void My_Delay(unsigned char z) ;
void main()
{
while(1)
{
MyBit = 1 ;
My_Delay(1500) ;
MyBit = 0 ;
My_Delay(1500) ;
}
}
void My_Delay(unsigned char z)
{
int i ;
for(i=0 ; i <= z ; i++) ; //to generate more delay you can use two for loops
}
Proteous Simulation of above code is here
Here i m gonna write a program to toggle a bit of port P0 of microcontroller using delay.
*/
#include<Reg51.h>
sbit MyBit = PO^1 ;
void My_Delay(unsigned char z) ;
void main()
{
while(1)
{
MyBit = 1 ;
My_Delay(1500) ;
MyBit = 0 ;
My_Delay(1500) ;
}
}
void My_Delay(unsigned char z)
{
int i ;
for(i=0 ; i <= z ; i++) ; //to generate more delay you can use two for loops
}
Proteous Simulation of above code is here