We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reset() 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; console.log(this); Pin.intervals[this] = setInterval(function() { on = !on; digitalWrite(pin, on); }, period); }; LED1.startFlashing(1000) ... undefined ERROR: Invalid pin! ERROR: Invalid pin! ERROR: Invalid pin! ERROR: Invalid pin! ERROR: Invalid pin! ... clearInterval(); LED1.startFlashing(1000); // works...
However:
reset() Pin.prototype.startFlashing = function(period) { console.log(this); var pin = this; if (Pin.intervals===undefined) Pin.intervals = []; if (Pin.intervals[pin]) clearInterval(Pin.intervals[pin]); var on = false; Pin.intervals[pin] = setInterval(function() { on = !on; digitalWrite(pin, on); }, period); }; LED1.startFlashing(1000); // works
It seems that just calling Pin.intervals[this]; somehow resets this
Pin.intervals[this];
this
The text was updated successfully, but these errors were encountered:
f446bab
No branches or pull requests
However:
It seems that just calling
Pin.intervals[this];
somehow resetsthis
The text was updated successfully, but these errors were encountered: