3.1.4 Codes
Ace your homework & exams now with Quizwiz!
Flashlight Responding to Light Code
while(1 ==1) { if(SensorValue(lightSensor)>700) { turnFlashlightOn(flashlight,127); } if(SensorValue(lightSensor)<=700) { turnFlashlightOff(flashlight); } }
Flashlight Responding to Light and a Switch Code
while (condition)//repeat indefinitely { while (condition)//repeat while limitSwitch pressed { if (condition)//respond to lightSensor { } else { } } //do this when the limitSwitch is not pressed }
Blinking LED with Switch Code
ClearTimer(T1); while(time1(T1) < 20000) //Loop for 20 sec { turnLEDOn(green); wait(2); turnLEDOff(green); wait(2); }
