Quiz+5-10

Quiz 5-10:

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 once! 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 < 4) //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;">} <span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">}