Quiz+5-15

Quiz 5-15:

Write a program that would make your Robot traverse a square using functions. Note: each leg of the square is assumed to take 3 seconds at 25% power. The turns will also use 25% power but they will be a point turn not a swing turn. One last thing ... Use a loop and only make the robot go around the square twice! Good Luck!

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

void Turn { motor[motorB]=-25; motor[motorC]=25; 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 < 8) //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="font-family: 'Arial Black',Gadget,sans-serif;"><span style="color: #0000ff; font-family: 'Arial Black',Gadget,sans-serif;">}