Scott Penrose

JohhnyFive Events

Scott is an expert software developer with over 30 years experience, specialising in education, automation and remote data.

Johnny Five Events

Most of the objects emit events. A pin can be used like this:

        var out1 = new five.Pin(4);
        out1.on('high', function() {
                console.log('We got a high', this.addr);

Yes this is an output but you still get the events fired. Sometimes...

  out1.low(); out1.high();    // Triggers event
  out1.write(0); out1.write(1); // FAILS to trigger event
  board.digitalWrite(4, 0); board.digitalWrite(4, 1); // FAILS to trigger event

This means you have to be clever programmatically for calling the high/low method from a value, e.g. out1[ value ? 'high' : 'low'](); So be very careful.

  • Arduino
  • Javascript
  • Edison
  • RaspberryPi