How GPIO pins work
If we look at our last project, we can observe from the code that we're writing values to an Led
object in Johnny-Five, and it's changing the state and brightness of an LED. How does this work? While the in-depth details are beyond the scope of this book, we will go a little into how this works; this uses the concept of GPIO, or General-Purpose Input/Output, pins.
A GPIO pin is a pin that provides electric current to or reads electric current from a circuit. In our last project, we used this to provide varying levels of power to our LED. These pins can be configured by users (that's us!) to be used as input (read electric current) or output (provide electric current). For now, we're going to focus on the output pins, of which there are two main types: Digital and PWM.
Digital output pins
Digital output pins are only capable of providing two levels of electric current to our circuits: 1
and 0
, HI
and LOW
, or ON
and OFF
. This means if we plug an LED into...