I just received my espruinos and started typing a few examples.
I have upgraded the firmware as explained in the quick start guide and I am following this tutorial: http://www.espruino.com/Flashing+Lights
The code under "try 4" is not working as expected:
Pin.prototype.startFlashing = function(period) {
var on = false;
setInterval(function() {
on = !on;
digitalWrite(this, on);
}, period);
}
LED1.startFlashing(100);
On the console I can read "ERROR: Invalid pin!". There seems to be a problem handling "this", in fact the issue seems to be the same as in this other forum post: http://forum.espruino.com/conversations/389/
The code works fine with the following modification:
Pin.prototype.startFlashing = function(period) {
var me = this;
var on = false;
setInterval(function() {
on = !on;
digitalWrite(me, on);
}, period);
}
LED1.startFlashing(100);
Just letting you know, I don't know this should be considered a bug in the code or in the documentation.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hello,
I just received my espruinos and started typing a few examples.
I have upgraded the firmware as explained in the quick start guide and I am following this tutorial: http://www.espruino.com/Flashing+Lights
The code under "try 4" is not working as expected:
On the console I can read "ERROR: Invalid pin!". There seems to be a problem handling "this", in fact the issue seems to be the same as in this other forum post: http://forum.espruino.com/conversations/389/
The code works fine with the following modification:
Just letting you know, I don't know this should be considered a bug in the code or in the documentation.
Thanks a lot!