Project Description:
In this project we connect three LEDs at three different pin (Port2_0, Port_1, Port_2) of Port 2.And it will blink after certain delay. For doing that we have to send different bit pattern with fixed delay to on-off LED. To glow the LED connected on Port2_0 bit pattern will be “00000001”, for Port2_1 bit pattern will be “00000010” and for Port2_2 bit pattern will be “00000100”.In bellow we will see the circuit diagram in Proteus simulation of our project “LED blinking by 8051 microcontroller using mikro c pro for 8051”.
Here you will find the embedded C program written in Mikro c pro for 8051.
Embedded C Code
// Name : LED blinking by 8051 microcontroller using mikro c pro for 8051
// Author : soufian soltan
// Date : 26-07-14
// Website : http://www.louhla.tk/
// Author : soufian soltan
// Date : 26-07-14
// Website : http://www.louhla.tk/
void main() {
while(1)
{P2 = 0b00000001; // Turn ON diodes on PORT2_0 bit
delay_ms(200);
P2 =0B00000010;
delay_ms(200);
P2 =0B00000100;
delay_ms(200);
}
}
while(1)
{P2 = 0b00000001; // Turn ON diodes on PORT2_0 bit
delay_ms(200);
P2 =0B00000010;
delay_ms(200);
P2 =0B00000100;
delay_ms(200);
}
}