For the next project, we're going to look at the
Led
object API and test several different methods. This is one of the benefits of Johnny-Five—abstraction. If you can understand the concept of an LED, you can use the Johnny-Five LED object without thinking about the underlying pins or timings. Let's go over the methods that we'll use for our project:
on()
andoff()
: These turn an LED on and off. Under abstraction, this sets the pin that is wired to the LED toHIGH
andLOW
, respectively. We'll be using these in the REPL.blink(time)
: This turns an LED on and off at a given interval.strobe()
andblink()
are aliases of each other and do the same thing.pulse(time)
: This will cause an LED to pulse on and off in an eased manner. This requires an LED wired to a PWM pin. Thetime
argument sets the length of each side of the pulse—500
will mean the LED will fade in for 500 ms and fade out for 500 ms, meaning a 1-second pulse.