Quiz+5-2

Quiz 5-2:

Your Robot has a touch sensor in front (TOUCH1) and a touch sensor in back (TOUCH2). Write a program that will allow the Robot to go forward until the front sensor is touched. It will then go backwards until the back sensor is touched. It will then go forward until the front sensor is touched. Yes it will keep going forwards and backwards until the battery runs down. Good Luck :)

task main { while(1) // Infinite Loop :) Keep it Up!!! { while(SensorValue(TOUCH1) == 0) // Boogie Forward till hit {  motor[motorB] = 50;  motor[motorC]= 50; }

while(SensorValue(Touch2) == 0) // Boogie Backward till hit <span style="color: #008080; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;">{ <span style="color: #0000ff; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;"> motor[motorB] = -50; <span style="color: #0000ff; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;"> motor[motorC]= -50; <span style="color: #0000ff; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;">} <span style="color: #0000ff; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;">}

<span style="color: #0000ff; font-family: 'Lucida Sans Unicode','Lucida Grande',sans-serif;">}