task main() { //Program begins, insert code within curly braces while(1 == 1) { if (SensorValue(lightSensor) > 700) { turnFlashlightOn(flashlight, 127); } if (SensorValue(lightSensor) <= 700) { turnFlashlightOff(flashlight); } } }
task main() { //Part 2) while (1==1) //repeat indefinitely { while (SensorValue(limitSwitch)==1) //repeat while limitSwitch pressed { if (SensorValue(lightSensor) >1500) //respond to lightSensor { turnFlashlightOn(Flashlight, 150); } else { turnFlashlightOff(Flashlight); } } turnFlashlightOff(Flashlight); //do this when the limitSwitch is not pressed } }