Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

4. Arduino > Touring an Arduino Board

Touring an Arduino Board

Now that you know how to install the Arduino IDE and drivers, you can move on to looking at the boards themselves. Since the Uno is the easiest and most straightforward of the boards, we’ll contrast that one with some of the other Arduino controllers so you understand not only what the Uno is, but what makes it unique.

The Controller

So, what is this controller? Really, it’s just the same thing as your average computer, minus the hard drive and a few other things you might be used to having. The core elements are there, however. Input/Output (I/O) is done through pins and the USB port, the processor is there, and there is a small amount of random access memory (RAM) that acts much the same as RAM in a larger computer. Of course, all of these things are on a far smaller scale than a laptop or desktop computer, which means that the engineering is quite different in some respects, and there are many different issues that you need to consider with a microcontroller that you would not need to consider with a normal computer, particularly when working with powering other devices and powering the controller itself. That said, the general principles still apply, which makes working with microcontrollers a good way to learn more about the inner workings of computers and of computing.

Uno Versus Mini Versus Mega

We’ll be looking at three controllers. The Uno controller, shown in Figure 4-7, is a slightly larger controller that is a little easier to work with for beginners, since components can be attached directly to the controller.

Arduino Uno controller

Figure 4-7. Arduino Uno controller

The other Arduino controller that we’ll examine is the Mini. This controller is much smaller, and that changes the types of projects that it can be used with. The Mini requires a separate USB adapter (see Figure 4-8) that allows you communicate with the controller over USB for uploading code and receiving messages over the Serial port. The Mini also requires that you purchase a prototyping board in order to wire any components to it or to power it separately from a computer using a battery. This isn’t a great impediment, and you should purchase a prototyping board anyway for doing any kind of serious work with the Arduino controller.

Arduino Mini and Programmer

Figure 4-8. Arduino Mini and Programmer

The Uno comes with small LED lights that you’ll find next to the USB port on the Uno. When you connect the controller to power, if there is a program currently loaded into the memory of the controller, a light should begin blinking. The Mini does not have such an easy way to tell that it’s plugged in and powering up correctly, but making a small program that can turn on an LED that is connected to one of the Mini’s pins is easy enough to do. We’ll cover doing that a little bit later in the section Hello World.

Uno means 1 in Italian and was created to mark the release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward, so learning about the Uno is a great way to learn the core fundamentals of the Arduino environment. It is designed to be easy to understand and to work for those without experience in electronics. It has 20 pins (6 analog and 14 digital), 6 pulse-width modulation-enabled pins, a TX and RX pin pairing, and an I2C port. Newer boards (after revision 3) have four additional convenience headers that mirror other pins on the board. None of that makes sense? Then read on.

What’s a pin?

A pin provides an input or output through which the controller can communicate with components. Smallish copper wires can be inserted into the pins connectors, and you’re off to the races. When you look at the Uno, you’ll see a row of small black holes along either side of the controller that a wire can be inserted into.

Digital versus analog pins

Digital pins have two values that can be read or written to them: high and low. High means that 5 volts (V) is being sent to the pin either from the controller or from a component. Low means that the pin is at 0 V. Now, start to imagine the sorts of information that this can encompass: on/off, there/not there, ready/not ready. Any kind of binary information can be read or written to a digital pin.

Analog pins are slightly different; they can have a wide range of information read or written to them. How wide a range? Well, from 0 to 255 can be written, which represents 256 steps of voltage information, once again starting with 0 V and going up to 5V. Analog values from 0 to 1,023 can be read (representing voltages from 0 to 5 V in 0.005 V increments). These pins are what we use to read and write information that has a range of values, such as the position of a dial, the distance of an object from an infrared sensor, or the brightness of an LED light. In addition to the digital and analog pins, there are connectors relating to the powering of components.

Figure 4-9 shows the Uno. Note that the digital pins are at the top of the picture. These are where you’ll plug in any controls that communicate using digital signals, that is, either an on or off state. We’ll talk more about this later in this chapter, but for the moment, understand that when we’re referring to the digital ports, the ports at the top of the board are what we mean. Some of the ports are also enabled for pulse width modulation (PWM), which means, in essence, that they can be used to send analog information to a component. Those are ports 3, 5, 6, 9, 10, and 11, you can notice them by the tilde ~ next to the number. That means that these ports can be set to do things other than just digital communication. The possible values of these pins is IN (that is, the information is coming from the component to the control) and OUT (meaning the information is going to the component from the controller).

Arduino Uno

Figure 4-9. Arduino Uno

At the bottom of the controller, we have the power connectors that provide 5V power, provide 3.3V power, and provide two ground pins that can be used to ground any components that you attach to the Arduino controller. Power, voltage, and ground are all defined at the end of the book, so if you’re not quite familiar with those terms, then make sure to read it.

Just to the right of the power pins are the Analog In pins. These allow you to receive analog information, that is, information in a range of voltage from 0 to 5V, in 4.9mV (millivolt) increments, which means that the analog information can be between 0 and 1,023. These pins are quite important, because many different types of controls send analog information in a range of values, such as a dial being turned or an infrared sensor sending range information.

Above the analog pins is the processor that the Arduino controller runs. Just above the processor is the reset button. This allows you to restart your program. This is important to know because the controller saves any program uploaded to it. So, if you write a program for your controller that is made to blink an LED on or off, it will begin running that program when you power up the Arduino. The reset button stops the program that is currently running. To change the program saved on the Arduino, you’ll need to clear the memory by uploading a new program. Just to the right of the reset button are the ICSP pins, which allow you to program the Arduino without using the USB cable (handy in some situations).

As a comparison, the Arduino Mini was first introduced in 2006 and is a space-saving alternative to the larger Uno. It can be so much smaller because it uses a different processor package, does not have the same easy-access pins that the Uno has, and requires a USB adapter that can communicate with the computer over USB. That said, the size of the controller means you can use it in projects where space is truly at a premium.

Pins on the Mini

When you turn over the Mini controller, you’ll see a row of small copper pins that represent each pin. These function in the same way as the connectors on the Uno, but where you can simply insert a wire into the Uno, you’ll need to insert the Mini into a prototyping board and then attach a wire to the same line on the board, as shown in Figure 4-10.

Connecting the Arduino Mini to the Programmer

Figure 4-10. Connecting the Arduino Mini to the Programmer

The Mini has 14 digital pins, which, as you can see in the diagram in Figure 4-10, has 8 along the left side of the board and 4 more along the bottom of the right side. Since the pins are not marked on the Mini as they are on the Uno, it’s important to know which pin is which. Above the four digital pins on the right side of the controller are the four analog pins. Unlike the Uno, all of these can be set to read data in or write data out. The other four analog pins (4–7) are at the bottom of the controller in a square-shaped formation.

Next to analog pins 4–7 are a pair of power pins, a ground pin, and a +5V pin to power components. Looking at the Mini, there are 3 +5V power pins and 4 ground pins, one on each side of the board. This makes the Mini even better suited for working in tight places, because grounding pins can be accessed from all sides of the controller, a real blessing when space is at a premium.

Pins on the Mega

For comparison, we’ll take a look at the Arduino Mega now, to show what you can get for a little extra space and battery drain. The Arduino Mega 2560 has 54 digital input/output pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. So you have four times the number of PWM pins and analog in pins as the Uno, which makes the Mega a formidable tool for larger systems. You’ll need to consider that it still pushes the same amount of current though, so you won’t be able to drive servos on all those pins without an external power supply.

As of the writing of this book, these are just some of the other Arduino controllers:

Nano

A compact board designed for breadboard use, the Nano connects to the computer using a Mini USB B cable.

Ethernet

The Ethernet Arduino controller contains an Ethernet controller and port so that the board can connect to a wired network via Ethernet.

LilyPad

Designed for wearable application, this board can be sewn onto fabric and is a stylish purple.

Pro

This board is designed for advanced users who want to leave a board embedded in a project. It’s cheaper than an Uno and easily powered by a battery, but it requires additional components and assembly.

Pro Mini

Like the Pro, the Pro Mini is designed for advanced users requiring a low-cost, small board and willing to do some extra work.

There are also numerous non-Arduino microcontroller boards that are quite similar to the Arduino: Teensy, Freeduino, Sanguino, Bare Bones Board, LEDuino, and Miduino, among others. The nice thing is that once you’ve learned the basics of using one of these boards, you can apply that knowledge to using any of the others depending on your preference and the particulars of your project.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint