Chapter 14. Arduino and Raspberry Pi

14.0. Introduction

A common alternative to using an interface board, such as a PiFace (Recipe 8.16), is to connect a Raspberry Pi to an Arduino board, as shown in Figure 14-1.

An Arduino Uno board
Figure 14-1. An Arduino Uno board

Arduino boards are superficially a little like a Raspberry Pi in that they are small and essentially a computer. However, Arduino boards are very different from the Raspberry Pi in a number of respects:

  • They do not have any interface to keyboard, mouse, or screen.
  • They have just 2 KB of RAM and 32 KB of flash for storing programs.
  • Their processor runs at just 16 MHz compared with the Raspberry Pi’s 700 MHz.

This might lead you to wonder why you would use such an apparently feeble board rather than the Raspberry Pi directly.

The answer is that Arduino boards, the most common being the Arduino Uno, are better than the Raspberry Pi at interfacing to external electronics in several ways. For example, Arduino boards have:

  • 14 digital inputs/outputs, like the Raspberry Pi’s GPIO pins, but each pin can provide up to 40 mA compared with the Raspberry Pi’s 3 mA. This enables them to power more devices without the need for extra electronics.
  • 6 analog inputs. This makes connecting analog sensors much easier (see Chapter 12).
  • 6 PWM outputs. These outputs are hardware-timed and produce a much more accurate PWM signal than can be achieved with the Raspberry ...

Get Raspberry Pi Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.