mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
17 lines
429 B
JavaScript
17 lines
429 B
JavaScript
// From http://www.espruino.com/Flashing+Lights
|
|
|
|
Pin.prototype.startFlashing = function(period) {
|
|
if (Pin.intervals==undefined) Pin.intervals = [];
|
|
if (Pin.intervals[this]) clearInterval(Pin.intervals[this]);
|
|
var on = false;
|
|
var pin = this;
|
|
Pin.intervals[this] = setInterval(function() {
|
|
on = !on;
|
|
digitalWrite(pin, on);
|
|
result = 1;
|
|
}, period);
|
|
}
|
|
|
|
D0.startFlashing(10);
|
|
setTimeout("clearInterval()",100);
|