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—such as LCD screens—that need bytes of information. These devices need these protocols to effectively communicate and receive the data they need.

The I2C and SPI protocols allow us to unlock an entirely new dimension of data for small projects—we can use many more devices with way fewer pins.

First, we'll take a look at the SPI protocol—this protocol allows us to send a lot of data in a much easier way than previous setups.

..................Content has been hidden....................

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