1-) The program below uses conditional statements to control the robot\'s action
ID: 3564356 • Letter: 1
Question
1-) The program below uses conditional statements to control the robot's actions shown. Match the best descriptions for the actions of the robot given the sensor inputs shown.
void loop()
{
//Check the light sensors
int leftLightSensorValue = getLeftLightSensor();
int rightLightSensorValue = getRightLightSensor();
if( leftLightSensorValue <= 38 )
{
leftForward( 100 );
rightForward( 100 );
} else
{
leftForward( 100 );
rightBackward( 100 );
} else
if( rightLightSensorValue >54 )
{
rightBackward( 100 );
leftBackward( 100 );
delay(10000)
}
}
____Robot goes backward for 25 seconds then spins right
____Robot will Move Backward
____Robot Goes Forward
____Robot Spins Right for 25 seconds, then goes backward
2-) The program below uses a set of if statements to to control the robot's motion. For the sensor reading shown, match the combination of sound indications that will be activated.
void loop()
{
//Check the light sensors
int leftLightSensorValue = getLeftLightSensor();
int rightLightSensorValue = getRightLightSensor();
if( leftLightSensorValue <= 38 )
{
leftBackward( 100 );
} else
{
leftForward( 100 );
} else
if( rightLightSensorValue <=18 )
{
rightBackward( 100 );
} else
{
rightForward( 100 );
}
}
____Spin Left
____Go Backward
____Spin Right
____Go Forward
3-) The program shown here operates the motors for 2 seconds. Match the sensor reading to the appropriate description of robot motion.
int leftLightSensorValue = getLeftLightSensor();
if( leftLightSensorValue > 38 )
{
if( leftLightSensorValue > 45 )
{
//Go forward
leftForward( 100 );
rightForward( 100 );
} else
{
//Spins left
leftBackward( 100 );
rightForward( 100 );
}
} else
{
if( leftLightSensorValue > 31 )
{
//Spins right
leftForward( 100 );
rightBackward( 100 );
} else
{
//reverse
leftBackward( 100 );
rightBackward( 100 );
}
}
delay(2000);
leftBackward( 0 );
rightBackward( 0 );
____Moves Forward
____Moves in Reverse
____Spins Left
____Spins Right
4-) The program below uses subroutines to move the robot. For the values of X shownMatch the motion of the robot.
void spinRight()
{
leftForward( 100 );
rightBackward( 100 );
delay(2000);
leftForward( 0 );
rightForward( 0 );
}
void spinLeft()
{
leftBackward( 100 );
rightForward( 100 );
delay(2000);
leftForward( 0 );
rightForward( 0 );
}
void goForward()
{
leftForward( 100 );
rightForward( 100 );
delay(2000);
leftForward( 0 );
rightForward( 0 );
}
void setup() // Built in initialization block
{
spinLeft();
if( X == 1 )
{
goForward();
}
if( X == 2 )
{
spinLeft();
}
if( X == 3 )
{
spinRight();
}
goForward();
}
____X=1
____X=3
____X=2
A. leftLightSensorValue == 42, rightLightSensorValue becomes less than 54 after 25 seconds B. leftLightSensorValue == 18, rightLightSensorValue == 59 C. leftLightSensorValue == 18, rightLightSensorValue == 12 D. leftLightSensorValue == 42, rightLightSensorValue becomes greater than 54 after 25 secondsExplanation / Answer
1)
A
B
C
D
---------------------------------------------------------------------------------------
2)
B
D
C
A
-------------------------------------------------------------------------------------------------------------------------------
3)
B
A
C
D
------------------------------------------------------------------------------------------------------------------------------------------
4)
A
B
C
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.