How to do if else condition in microC
时间:03-31
整理:3721RD
点击:
actually in this program, i want the program to achieve 2 condition(condition 1,condition 2) in order to on a led, condition 1(A == 0) must archive first in order to proceed to condition 2(B == 0), then the led on when both 2 condition achieve .
In this program below, i have a problem with the led will on when (no wander which condition achieve first).
pls help me to do correction in this program
thank
#define A PORTD.F1
#define B PORTD.F2
#define led PORTB.F2
void main()
{
trisd=0xFF;
trisb=0x00;
portd=0xFF;
portb=0x00;
while(1)
{
if (A == 0)
{
if (B == 0)
{
led=1;
}
else
{
led=0;
}
}
else
{
led=0;
}
}
}
In this program below, i have a problem with the led will on when (no wander which condition achieve first).
pls help me to do correction in this program
thank
#define A PORTD.F1
#define B PORTD.F2
#define led PORTB.F2
void main()
{
trisd=0xFF;
trisb=0x00;
portd=0xFF;
portb=0x00;
while(1)
{
if (A == 0)
{
if (B == 0)
{
led=1;
}
else
{
led=0;
}
}
else
{
led=0;
}
}
}
Will this work?
Code:
while(1) { if((A != 0) && (B != 0)){ led = 0; } if((A == 0) && (B != 0)) { while((A == 0) && (B != 0)) { if((A == 0) && (B == 0)) { led = 1; break; } } } }
- Any conditions or prerequisites on simultatin dielectric objects ?!
- Defining boundary condition in electrostatic solver in Comsol
- Why do i need periodic boundary conditions in order to calculate reflection. c?
- Boundary condition error in hfss
- Transparent Boundary Condition
- appropriate boundary condition for PCB in CST