In: Computer Science
In RVW complete the following Sensor Challenges: Hand in your code for each challenge (you can paste into one document)
Try – it Forward until Touch Move the robot to the obstacle. Once the robot touches the obstacle it stops
Vacuum Challenge – Using the touch sensor, the robot needs to touch all four walls in the room
Arm Position Classic - For this challenge, The robotic arm is configured with the Touch Sensor attached so that it when the arm is fully upright the button on the Touch Sensor is pushed in. The starting point of the challenge has an object approximately 5 rotations length away from the robot. Starting with the arm in the ‘down’ position, program the robot to raise its arm until the touch sensor is pushed in, move forward 5 rotations, lower the arm around the object, and then bring the object back to the starting location.
Threshold Value - Using the Ultrasonic Sensor, set the threshold value so that the robot plays a sound when it detects an object within 10cm of the sensor.
Backward until far - Place a robot close to a wall with the Ultrasonic Sensor facing directly at it. Program the robot to move backward until the Ultrasonic Sensor reads a value greater than 30cm, and then stop.
Submit to Blackboard:
A document that contains your code for each of the above challenges.
Click on the badges icon to view your badges. In the same document, a screen shot of the badges earned to show you completed the challenges successfully. Although the screen shot below shows two challenges completed, yours should have five completed.
soln: try it
task main()
{
repeat(forever)
{
setMotorSpeed(leftMotor , 60);
setMotorspeed(rightMotor,60);
waitUntil(getTouchValue(touchSensor) == 1);
{
setMotorSpeed(leftMotor , 0);
setMotorspeed(rightMotor,0);
}
}
}
answer 2:
task main()
{
repeat(forever)
{
setMotorSpeed(leftMotor , 60);
setMotorspeed(rightMotor,60);
waitUntil(getTouchValue(touchSensor) == 1);
turnRight(90 ,degrees , 60);
{
waitUntil(getTouchValue(touchSensor) == 1);
turnRight(90 ,degrees , 60);
{
waitUntil(getTouchValue(touchSensor) == 1);
turnRight(90 ,degrees , 60)
{
waitUntil(getTouchValue(touchSensor) == 1);
turnRight(90 ,degrees , 60)
}
}
}
}
answer abc:
task main()
{
repeat(forever)
{
setMotorSpeed(leftMotor , 60);
setMotorspeed(rightMotor,60);
waitUntil(getTouchValue(touchSensor) == 1);
{
waitUntil(getDistanceValue(Ultrasonic Sensor) == 10);
{
ap.loadSoundSet("Aldebaran"); fileId = ap.post.playSoundSetFile("filename");
}
setMotorSpeed(leftMotor , 0);
setMotorspeed(rightMotor,0);
waitUntil(getDistanceValue(Ultrasonic Sensor) == 10);
{
movereverse (waitUntil(1,getDistanceValue(Ultrasonic Sensor) == 30);
}
}
}