Quiz+5-12

Quiz 5-12:

Write a program that would make your Robot traverse a square using functions. Note: each leg of the square is assumed to take 2 seconds at 50% power. One last thing ... Use a loop and only make the robot go around the square 50 times! Look at 5-10 or 5-11 and adjust the code just a little, (that was a big HINT). Good Luck!

int C; void Straight { motor[motorB]=50; motor[motorC]=50; wait1Msec(2000); }

void Turn { motor[motorB]=50; motor[motorC]=0; wait1Msec(700); }

task main <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">{ <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">C=0; <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">while(C < 200) //Note it will work on 0,1,2, and 3 which is 4 times! <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">{ <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">Straight; <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">Turn; <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">C=C+1; <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">}