Although the Arduino and Raspberry Pi are both small, credit cardsized circuit boards, they are actually quite different devices. The Arduino is a very simple microcontroller board that does not run an operating system of any sort, whereas the Raspberry Pi is a tiny computer that runs Linux and also happens to be able to interface to external electronics.
Raspberry Pi
If you are new to electronics, but comfortable using computers, then the Raspberry Pi is going to be the more familiar device. The Raspberry Pi () really is a very small version of a regular computer running Linux. It has USB ports for you to attach a keyboard and mouse as well as HDMI video output to connect to a monitor or TV and audio output.
Figure 1-1. A Raspberry Pi 2
The Raspberry Pi has an Ethernet port to connect it to your network and will also accept USB WiFi adapters. Power is supplied to the Raspberry Pi using a microUSB socket.
A microSD card is used for storage rather than a conventional disk drive. This card contains both the operating system and all your documents and programs.
The Raspberry Pi was created in the UK, primarily to serve as a low-cost computer to help with teaching computer basics, particularly Python programming, to school kids. In fact, the name Pi is said to be derived from the Py of Python.
A few things set the Raspberry Pi apart from a regular desktop or laptop computer running Linux:
- It costs just $40 (a cut-down Raspberry Pi called the model A+ is also available for a lower price and the model zero for an even lower price).
- It uses under 5 watts of power.
- The Raspberry Pi has a double row of general-purpose input/output (GPIO) pins. From these pins, you can control LEDs, displays, motors, and all the different types of output devices that you will work with later in this book.
In addition, the Raspberry Pi can also be connected to the Internet using WiFi or a LAN cable, making it suitable for Internet of Things projects ().
The specs for the Raspberry Pi 2 (the latest and best version at the time of writing) are as follows:
- ARM v7 900 MHz quad-core processor
- 1 GB DDR2 memory
- 10.100 BaseT Ethernet
- 4 USB 2.0 ports
- HDMI video out
- Camera interface socket
- 40-pin GPIO header (all pins operate at 3.3V)
If you are new to Raspberry Pi, there is a primer to get you up and running with the hardware and also the Python programming language in .
Arduino
There is quite a wide range ). The Arduino is a little cheaper than a Raspberry Piyou can purchase an Arduino Uno for around $25.
Figure 1-2. An Arduino Uno Revision 3
If you are accustomed to working on a regular computer, the Arduinos specifications will probably seem grossly inadequate. It has just 34 KB of memory (of various types). That means that the Raspberry Pi has roughly 30,000 times as much memory, without even including the flash memory of the Pis SD card! Whats more, the Arduino Uno has a processor clocked at just 16MHz. You cannot attach a keyboard, mouse, or monitor to the Arduino, and it does not run an operating system.
You may wonder how this little device can actually do anything useful. The secret to the Arduinos usefulness lies in its very simplicity. There is no operating system to boot up, or other interfaces that you may not need in a project that would simply add cost and consume power.
Whereas the Raspberry Pi is a general computer, the Arduino concentrates on doing one thing wellconnecting to and controlling electronics.
To program an Arduino, you need a regular computer (you can even use a Raspberry Pi if you want). On the computer you choose, youll need to run an integrated development environment (IDE), which allows you to write a program to be downloaded to the built-in flash memory on the Arduino.
The Arduino can only run one program at a time, and once it is programmed, it will remember that program and automatically run it as soon as it is powered up.
Arduinos are designed to accept shields, which are boards thatplug on top of the Arduinos input/output sockets and add extra hardware features, such as various types of display, as well as Ethernet and WiFi adapters.
You program an Arduino using ).
Choosing a Device: Arduino or Pi?
One of the reasons this book explains how to connect electronics to both Arduino and Raspberry Pi is that some projects are better suited to a Raspberry Pi and some to an Arduino. Other boards that lie in between these extremes are generally close enough to either an Arduino or Raspberry Pi that this book will be of use in working out how to use them.
When embarking on a new project, my rule of thumb is to use an Arduino by default. However, if the project has one of the following requirements, then a Raspberry Pi is probably a better choice:
- Internet or network connectivity
- The need for a large screen
- The need to attach keyboard and mouse