You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Notice the 'funny' & and | in the set

    var pulse = function(led,stp) {
      var ity = 0;
      return function(){
        analogWrite(led, 
          (ity += stp) < 0
           ? ity = 0 & (stp = - stp)
           : (ity > 1)
             ? ity = (stp = - stp) | 1
             : ity
         );
        console.log(ity);
      };
    };
    

    Has the issue with repeating 0 and 1 with 1 / stp being a whole number, but working for all other stp. Changing the comparison from < and > to <= and >= works just the other way round.

About

Avatar for allObjects @allObjects started