colorLeds[i].blink()
Makes the color LEDs blink.
Toggles the color LEDs on and off at a rapid or slow pace depending on the interval chosen. The interval is just the amount of time (in milliseconds) between the blinks, making 50 a small number for a fast pace and 100 a big number for a slower pace. If you choose to leave the interval parameter empty, the color led will blink at a rate of 100 milliseconds by default.
Examples
Blink Shrinker
Increases the blink rate with each button press
var interval = 100;
onBoardEvent(buttonL, "press", function(event) {
interval = interval - 5;
colorLeds[0].blink(interval);
colorLeds[1].blink(interval);
colorLeds[2].blink(interval);
colorLeds[3].blink(interval);
colorLeds[4].blink(interval);
});
Alternating Blinks
Blinks every other led at a different interval
onBoardEvent(buttonL, "press", function(event) {
colorLeds[0].blink(100);
colorLeds[1].blink(50);
colorLeds[2].blink(100);
colorLeds[3].blink(50);
colorLeds[4].blink(100);
});
Simple Button Press
onBoardEvent(buttonL, "press", function(event) {
colorLeds[0].blink();
});
Syntax
colorLeds[index].blink(interval)
Parameters
Name | Type | Required? | Description |
---|---|---|---|
interval | number | The number of milliseconds in between blinks for the LED. |
Found a bug in the documentation? Let us know at support@code.org.