Avatar for NightlyNexus

NightlyNexus

Member since Feb 2014 • Last active Feb 2014
  • 1 conversations
  • 2 comments

Student at Georgia Tech.
Android Developer.

Most recent activity

  • in JavaScript
    Avatar for NightlyNexus

    I am following the example in Try 4. I entered

    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);
    }, period);
    };
    

    But, when I run "LED1.startFlashing(1000);" in the terminal, I get "ERROR: Invalid pin!"
    "console.log(pin);" prints "=undefined" so something is very wrong.
    However, when I run "var light = LED1;" and then "light.startFlashing(1000);" I get the expected behavior.
    What is going on here? I am a Java developer and don't use JS that much, so I may be misunderstanding something simple.

Actions