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.
onBoardEvent(toggleSwitch, "close", function(event) { led.pulse(200); }); onBoardEvent(toggleSwitch, "open", function(event) { led.blink(200); });
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); });
onBoardEvent(buttonL, "down", function(event) { led.pulse(200); }); onBoardEvent(buttonL, "up", function(event) { led.off(); });
led.pulse(interval);
Name | Type | Required? | 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. |
Found a bug in the documentation? Let us know at documentation@code.org