Recall from our initial discussion in Chapter 1, “What is the Raspberry Pi?” that a microcontroller is a PCB that is designed primarily for a small number of time-dependent tasks.
The big benefit of integrating your Raspberry Pi with a microcontroller is that you can connect to an almost endless number of analog and digital sensors. This means you can write programs that detect and take action on the following and more:
The Arduino platform (www.arduino.cc) is a suite of electronics prototyping PCBs that are dearly loved by artists, designers, inventors, and hobbyists for their ease of use and flexibility.
Hobbyists have developed some pretty cool technology by using Arduino microcontrollers: motion sensors, home automation systems, MIDI controllers, radon detectors...the list of project ideas is seemingly endless.
The Raspberry Pi–Arduino heavenly match is discussed in Chapter 19, “Raspberry Pi and Arduino.” For now, however, let’s go over the basic “gotchas” of this electronic marriage:
Connection options: To connect your Raspberry Pi to an Arduino board, you can either use a USB cable or a I2C (pronounced eye-squared-see) serial link. You can see the Pi and Arduino UNO lined up side-by-side in Figure 3.5.
FIGURE 3.5 You can connect an Arduino board directly to the Raspberry Pi by using USB, serial, or GPIO connections.
- Voltage differences: We already know from Chapter 2, “Hardware Components Quick Start,” that the Raspberry Pi accepts 5V inbound power but operates at 3.3V internally. By contrast, the Arduino operates externally and internally at 5V. Consequently, when joining Pi with Arduino you need to invest in an external voltage regulation solution to avoid burning up your Pi.
- Administration: Recall that the lack of an operating system is one of the defining characteristics of a single-board microcontroller. Therefore, in an Arduino/Raspberry Pi nexus, all your Arduino programming happens on the Pi, and you upload your Arduino “sketches” to that hardware over the serial or USB connection.
Please note that despite its overwhelming popularity, the Arduino is not the only single-board microcontroller game in town. Here’s a quick list of single-board microcontroller vendors that you might find useful: