Microcontroller › 8051 › How to use IF statement with 8051? › How to use IF statement with 8051?
August 26, 2015 at 5:22 am
#13219
Prabakaran P M
Participant
Here is the code:
#include <reg51.h>
sbit S1 = P2^0;
sbit S2 = P2^1;
sbit Led = P1^0;
sbit Led2 = P1^1;
void main()
{
S1 = 1;
S2 = 1;
while(1) // For ever
{
if(S1 == 0)
{
Led = 0;
while(S1 == 0);
}
Led = 1;
}
{ ////// remove this curly bracket
if (S2 == 0)
{
Led2 = 0;
while (S2 == 0);
}
Led2 = 1;
}
}