Why do we need the I2C and SPI protocols?
This is all starting to get really complicated, right? Why even bother? We have digital pins and analog pins; shouldn't reading values from these be enough?
Not when you go outside the realm of LEDs. Think about how much information goes into this text you're reading on a page (or, likely, a screen)! Bytes and bytes of information. This is true for many peripherals you'll use in Johnny-Five applications.
For instance, the accelerometer we'll be using—without the I2C protocol, it would use three analog pins. That's the majority of the analog pins on an Arduino Uno, and many platforms don't have analog pins at all! Not to mention the LCD we used in Chapter 4, Using Specialized Output Devices—without I2C, we have to correctly wire 11 different pins, six of which are separate data pins.
The complexity of data being sent and received is also an issue. There are sensors that send back data that doesn't fit in an analog range of 0
-1024
. There are output devices...