You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • What about having this global function uploaded? It will toggle any pin:

    function toggle(pin) { pin.write(pin, !pin.read(); }
    

    To be on the safe side - NOT make an input pin an output pin - use this code:

    
    function toggle(pin) {
      if (pin.getMode().indexOf("output") > -1) {
        pin.write(pin, !pin.read();
    } }
    

    ...and prototype-based-object-oriented, upload this expression, which will give you the .toggle():

    Pin.prototype.toggle = function(){ 
        if (pin.getMode().indexOf("output") > -1) {
          pin.write(pin, !pin.read();
      } }
    
About

Avatar for allObjects @allObjects started