Quiz+06

Robotics Quiz 6

Write a RobotC program to make your NXT do the following behaviors: NOTE: You need to use ALL FUNCTIONS  in task main.

Go Forward for 2.5 seconds at Full power (Call this function GoForward ). Swing Turn Right for 4 seconds (Call this function TurnRight ). Go Forward for 2.5 seconds at Full power. Swing Turn Right for 4 seconds. Go Forward for 2.5 seconds at Full power. Swing Turn Right for 4 seconds.

NOTE: I expect you to provide a line of <span style="color: #ff0000; font-family: 'comic sans ms',cursive; font-size: 36px;">COMMENT <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;"> for each behavior, you need to have a comment line above your function telling me what your function is going to do.

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">Yes, print first and last name at the BOTTOM along with DATE.

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">Answer:

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">// =================== Function Forward 2.5 seconds Full power <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">void GoForward <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">{ <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">motor[motorB]=100; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">motor[motorC]=100; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">wait1Msec(2500); <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">}

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">//=================== Function Swing Turn Right 4 seconds <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">void TurnRight <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">{ <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">motor[motorB]=0; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">motor[motorC]=50; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">wait1Msec(4000); <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">}

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">//========================== Main Program <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">task main <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">{ <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">GoForward; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">TurnRight;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">GoForward;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">TurnRight;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">GoForward;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">TurnRight;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">GoForward;

<span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">TurnRight; <span style="color: #0000ff; font-family: 'Comic Sans MS',cursive; font-size: 24px;">}