#pragma config(StandardModel, "EV3_REMBOT") //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// /* Create an autonomous program that uses the Color Sensor to switch the light on and off depending on the ambient light levels. Pressing the Touch Sensor overides the loop turning on the light regardless of the ambient light levels until the Touch Sensor is pressed again. NOTE: A sleep in the monitorTouchSensor task is used to replace the bump function in the EV3 software. */ task monitorTouchSensor() { //Wait for Touch Sensor to be touched. while(getTouchValue(touchSensor) ==0) { //Do nothing until touched. sleep(10); } //Stop task "main" (which is task #0) stopTask(0); //Display Image "Light on" on the LCD Screen. drawBmpfile(0, 127, "Light on"); sleep (1000); //Wait for Touch Sensor to be touched. while(getTouchValue(touchSensor) == 0) { //Do nothing until touched. sleep(10); } } task main() { startTask(monitorTouchSensor); //Loop forever while(true) { //Wait for the level of ambient light intensity to drop below 15. while(getColorAmbient(colorSensor) >= 15) { //Do nothing while we're waiting. sleep(1); } //Display Image "Light on" on the LCD Screen. drawBmpfile(0, 127, "Light on"); //Wait for the level of ambient light intensity to rise above 15. while(getColorAmbient(colorSensor) <= 15) { //Do nothing while we're waiting. sleep(10); } //Erase the display to clear the LCD screen. eraseDisplay(); } }