Input event handlers and output device manipulation

This is where the fun happens, we wait for input and manipulate outputs accordingly! This will watch for a button connected to P1–8 to be pressed, then turn on an LED. But how would we turn the LED off when the button is released? For that, we're going to take another look at the Johnny-Five documentation:

  // We'll go over more about the Button in the next section!
// This is still inside the board ready event handler!
button.on('press', () => {
led.on()
})
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.239.46