The led
is an object representing the red LED next to the USB port. Internally this LED is connected to pin 13 of the Circuit Playground.
led.on()
- Turn the red LED onled.off()
- Turn the red LED offled.toggle()
- Alternate between turning the LED on and offled.blink()
- Blink at a given rateled.pulse()
- Pulse at a given rateChanges the rate of how fast the button blinks depending on which button is pressed.
//Changes the rate of how fast the button blinks depending on which button is pressed. var blinkRate = 50; onBoardEvent(buttonL, "down", function(event) { blinkRate = blinkRate - 10; led.blink(blinkRate); }); onBoardEvent(buttonR, "down", function(event) { blinkRate = blinkRate + 10; led.blink(blinkRate); });
onBoardEvent(toggleSwitch, "close", function(event) { led.pulse(200); }); onBoardEvent(toggleSwitch, "open", function(event) { led.blink(200); });
onBoardEvent(buttonL, "down", function(event) { led.toggle(); });
The red LED light turns on when the switch is flipped open, and off when the switch is flipped closed.
//The red LED light turns on when the switch is flipped open, and off when the switch is flipped closed. onBoardEvent("toggleSwitch", "open", function(event) { led.on(); }); onBoardEvent("toggleSwitch", "closed", function(event) { led.off(); });
Found a bug in the documentation? Let us know at documentation@code.org