Robot skipping loop

0 votes
asked Jun 11, 2019 by pol
Robotc ev3

It skips directly to scan section

I want it to go forward initially backward then turn around

And scan using the ultrasound sensor

And attack if anybody spotted in proximity

#pragma config(Sensor, S3,     light,          sensorEV3_Ultrasonic)

#pragma config(Sensor, S4,     color,          sensorEV3_Color, modeEV3Color_Color)

#pragma config(Motor,  motorB,          B,             tmotorEV3_Large, PIDControl, encoder)

#pragma config(Motor,  motorC,          C,             tmotorEV3_Large, PIDControl, encoder)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()

{

 //int n=0;

long red, green, blue;

while(1==1)

{

 motor(B)=100;

 motor(C)=100;

 getColorRGB(S4,red,green,blue);

if(red>20 && green>20 && blue >20)              // reverse-turn - white line

{

motor(C)= -100;

motor(B)= -100;

wait1Msec(1000);

motor(C)= -100;

motor(B)=100;

wait1Msec(5000);

motor(C)= 100;

motor(B)= 100;

wait1Msec(2000);

}

while(getUSDistance(light)>40)  //scan

{

motor(C)=-100;   

motor(B)=100;

}

while(getUSDistance(light)<40)  //attack

{

motor(C)=100;

motor(B)=100;

}

   

}

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...