led

Category:Circuit

red led

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.

Properties and Methods

Examples

Blink: Blink Buttons

Changes 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);
});

Pulse: Pulse versus Blink

onBoardEvent(toggleSwitch, "close", function(event) {
  led.pulse(200);
});
onBoardEvent(toggleSwitch, "open", function(event) {
  led.blink(200);
});

Toggle: Button Lightswitch

onBoardEvent(buttonL, "down", function(event) {
  led.toggle();
});

On and Off: Lightswitch

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