Makes the red LED blink.
led.blink
toggles the LED on and off at a rapid or slow pace depending on the interval given. The interval is the time (in milliseconds) between blinks, meaning the bigger the number the slower the pace of the blinks.
onBoardEvent(buttonL, "press", function(event) { led.blink(200); });
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); });
If the led is blinking too slowly or too fast, stop the led altogether.
//If the led is blinking too slowly or too fast, stop the led altogether. var blinkRate = 50; onBoardEvent(buttonL, "down", function(event) { blinkRate = blinkRate - 10; led.blink(blinkRate); if(blinkRate < 10){ led.off(); } }); onBoardEvent(buttonR, "down", function(event) { blinkRate = blinkRate + 10; led.blink(blinkRate); if(blinkRate > 200){ led.off(); } });
led.blink(interval);
Name | Type | Required? | Description |
---|---|---|---|
interval | number | The time (in milliseconds) in between blinks. If left empty, the interval will default to 200. |
Found a bug in the documentation? Let us know at documentation@code.org