led.pulse()

Category:Circuit

Makes the red LED pulse at a specific interval.

While similar to led.blink(), the led.pulse() method turns the LED on and then slowly dims the light until the LED turns off again. So when the light is pulsing, it's not just turning on and off, it's lowering its brightness. Like led.blink(), led.pulse() takes an interval parameter to determine how fast the led should be pulsing.

Examples

Pulse versus Blink

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

Pulse Rates

onBoardEvent(toggleSwitch, "close", function(event) {
  led.pulse();
});
onBoardEvent(toggleSwitch, "open", function(event) {
  led.pulse(150);
});
onBoardEvent(buttonL, "down", function(event) {
  led.pulse(50);
});
onBoardEvent(buttonR, "down", function(event) {
  led.pulse(100);
});

Pulse On, Pulse Off

onBoardEvent(buttonL, "down", function(event) {
  led.pulse(200);
});
onBoardEvent(buttonL, "up", function(event) {
  led.off();
});

Syntax

led.pulse(interval);

Parameters

NameTypeRequired?Description
interval number The length of time (in milliseconds) that the light should be dimming for. If left empty, the interval will default to 200.

Tips

Found a bug in the documentation? Let us know at documentation@code.org