• As DrAzzy says, you need:

    var self = this;
    

    not:

    self = this;
    

    That's almost certainly your problem... Personally though I'd also skip defining the small second function, and do:

    var self = this;
    
    ...
      this.interval = setInterval(function ()  {
        digitalPulse(self.pin,1,self.pulse);
    //    print(self.pin);
      }, 20);
    

    That's the pattern we tend to use for modules, and while it involves writing self and not this, it is a bit more efficient both in speed and memory usage.

About

Avatar for Gordon @Gordon started