Quiz+5-4

Quiz 5-4:

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. Now I do not want you to forget how to make function calls, so you will have a function called : "GoForward" and one called "GoBackward". Yes you need to write the functions, Good Luck :)

void GoForward { motor[motorB] = 50; motor[motorC]= 50; }

void GoBackward { motor[motorB] = -50; motor[motorC]= -50; }

task main { while(1) Infinite Loop :) Keep it Up!!! <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;">while(SensorValue(TOUCH1) == 0) Boogie Forward till hit <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;">GoForward; <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;">while(SensorValue(Touch2) == 0) // Boogie Backward till hit <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;">GoBackward; <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;">}