• This is a working example I have come up with with your help, maybe it's of any use to others.

    Example of an Espruino Object that fires an event when the button on pin D17 is pressed.
    var P8 = {
      init : function(){
        },D17 ,{ repeat:true,debounce:25 }
    }; // end of P8 Object
    // ============================= test of P8 object  ===============
    P8.on('button', function(btn){ print("Button",btn, "press detected");});

    Output of the script when the button is pressed:
    Button D17 press detected

    In this example the init function needs to be called at start of the main script. Not sure if there is a way to move this init into the Object, but this works for me.


Avatar for gerardwr @gerardwr started