Alternates from turning the red LED on and off
Changes based on the current state of the LED. If the LED is on when you use led.toggle()
, then it will turn off after being called.
onBoardEvent(lightSensor,"data", function(event) { led.toggle(); });
Every third time you press the left button, toggle!
var buttonPress = 1; onBoardEvent(buttonL,"down", function(event) { if (buttonPress >= 3){ led.toggle(); buttonPress = 1; } else { buttonPress = buttonPress + 1; } });
onBoardEvent(buttonL, "down", function(event) { led.toggle(); });
led.toggle()
Found a bug in the documentation? Let us know at documentation@code.org