- Dec 11, 2002
- 18,409
- 40
- 91
So I'm building a fire extinguishing robot. I basically have two flame sensors on my robot. I want my robot to move forward when the front sensor sees the flame, and backwards if the rear sensor sees the flame.
It seems to want to run forwards and backwards simultaneously if either sensor sees the flame.
Why does the code run both conditionals if only one was met?
Here's my code:
void findflame()
{
while(SensorValue[rightEncoder] < 171)
{
orientflame();
if(SensorValue[flameF] > 500);
{
motor[motorR] = 40;
motor[motorL] = 40;
}
if(SensorValue[flameR] > 500);
{
motor[motorR] = -40;
motor[motorL] = -40;
}
stopdistance(5);
}
}
It seems to want to run forwards and backwards simultaneously if either sensor sees the flame.
Why does the code run both conditionals if only one was met?
Here's my code:
void findflame()
{
while(SensorValue[rightEncoder] < 171)
{
orientflame();
if(SensorValue[flameF] > 500);
{
motor[motorR] = 40;
motor[motorL] = 40;
}
if(SensorValue[flameR] > 500);
{
motor[motorR] = -40;
motor[motorL] = -40;
}
stopdistance(5);
}
}
