Electronics and the Fairy Dust - Giving Life to Objectss - The Maker's Manual: A Practical Guide to the New Industrial Revolution 1st Edition (2015)

The Maker's Manual: A Practical Guide to the New Industrial Revolution 1st Edition (2015)

Part IV. Giving Life to Objects

Life, do you hear me?

Give my creation life!

Dr. Fredrick Frankenstein

§ Chapter 15, Electronics and the Fairy Dust

§ Chapter 16, Arduino

§ Chapter 17, Expanding Arduino

§ Chapter 18, Raspberry Pi

§ Chapter 19, Processing

§ Chapter 20, The Internet of Things

Chapter 15. Electronics and the Fairy Dust

Tinker Bell and Peter Pan could fly thanks to a happy idea and some fairy dust. Our projects also need some fairy dust to fly, in the form of ghostly sub-atomic particles called electrons. Moving electrons are the basis of electricity, and their behavior in components is the basis of the field we call electronics. To a beginner, electronics may seem a difficult and inscrutable topic, and circuits as tiny and complicated objects. Electronics books are chock-full of math and physics formulae, so there is apparently nothing magic or fascinating... just a bunch of stuff an engineer would love!

But if you looked at it metaphorically, with an artist’s eye, you could see wires and currents as pipes and water, transistors and potentiometers as valves and taps... and you would find out that electronics can be pretty intuitive, and a lot of fun too!

Hello World!

When a programmer approaches a new computer language, she first checks that everything is properly installed on the computer, and that the development environment can compile her program. To do that, it’s become a programming tradition to write a program called “Hello World” as your first program. “Hello World” does nothing more than print the words “Hello World” on the screen. Ridiculously simple, yes, but successfully writing, compiling, and running the program tells you that your development environment works.

With electronic circuits, there usually isn’t a screen to display stuff on. So hardware hackers have developed their own tradition: they add an LED to the circuit. If the LED lights up, or blinks in a controlled manner, the circuit works.

What You Need

Let’s take a brief look at the list of materials you need. To light up an LED, the very first thing you need is ...an LED. LED stands for Light Emitting Diode, and in true engineering fashion those words describe it completely: it is a diode (a component that lets electricity flow through it in only one direction) that emits light. As you’ll see later when it comes to building the circuit, the diode function of LEDs is very important. LEDs are relatively cheap; they can be purchased in bulk on line for as little as 2 cents each. They’re available in nearly every color in the rainbow and beyond, from infrared to ultraviolet.

You can find everything you need for this project (except for the battery and tape) in Maker Shed’s Mintronics: Survival Pack. It includes the LED, the battery snap, and the resistor--among many other components you’ll find useful.

The second thing you need is a resistor. True to its name, a resistor resists the easy flow of electricity. Think of it as a sponge embedded in a hose, changing the flow of water (or electricity) from a torrent to a trickle. Resistors have different resistance values, from very weak to very strong, which are coded onto their surface in the form of stripes of many colors. For the purposes of this project, you’ll need a resistor that is striped orange, white, and brown. The fourth band is less significant, but is likely to be gold or silver. These colors indicate a resistor valued at 390 Ohms, but you can use a 1K Ohm resistor (brown, black, and red).

If you have a five-band (blue color) resistor, the first four bands of a 390 Ohm resistor will be orange, white, black, and black. The first four bands of a 1K Ohm five-band resistor will be brown, black, black, and brown.

To power the circuit you need some kind of energy source: the simplest solution is a 9 volt battery with a snap connector to wire it to the components. Finally, you will need some thin gauge electric wire to connect the parts together, and some insulating tape to connect everything.

A First Circuit

Start from the battery snap. If you buy your battery snap from an electronics retailer or online store like Maker Shed, the ends of the wire are probably already stripped. If you salvage the battery snap from a broken toy or radio, you’ll need to strip the ends yourself. Don’t use your teeth for stripping the wire! Use a dedicated wire stripper tool for this.

Twist the red wire from the battery clip around one of the resistor pins (either pin is OK--a resistor is not a diode so power can run through it in any direction) and wrap up the connection with some insulating tape to make the joint more stable. Cut off a few inches of narrow gauge electrical wire, and strip the insulation from a half-inch of both ends. Twist one end of the wire around the other resistor pin, and secure it with insulating tape. Right now, what you’ve got is simply an extension of the battery pack’s red wire, with a resistor added to it. Spread the LED’s pins, twist this wire around the longer LED pin, and secure it with tape. Finally, connect the shorter pin of the LED to the battery clip’s black wire. Figure 15-1 shows how the circuit is wired up.

Alt Text

Figure 15-1. Our very first circuit.

Now you just need to connect the battery and... Hello world!

Did You Burn Out Your LED?

If, instead of a happy glowing LED, you get a popping or snapping sound followed by a puff of smoke and an unpleasant smell, then you’ve just learned something important: you need to make sure the resistor’s connected properly before applying power. If you omit the resistor, or accidentally bypass it with untidy wiring, the LED will receive too much current and burn out.

If you are tempted to experience the destruction of an LED, take a few precautions: don’t hold the LED in your hand when you try it, wear safety glasses, and perform this test in a well-ventilated area. And enjoy!

Current, Voltage, and Resistance

What do water and electricity have in common? You’d be surprised. Water can help us understand how electricity works, because we can explain many phenomena in a simple way by comparing the two. The metaphor is neither new nor original, and it is often used by those who teach electronics.

Let’s first think about where electricity begins. Inside an atom (Figure 15-2), protons and neutrons make up the atomic nucleus, and electrons revolve around the nucleus. Electrical phenomena derives from the electrons’ properties. Protons have a positive charge, electrons have a negative charge, and neutrons have no charge.

Alt Text

Figure 15-2. A lithium atom drawn with OpenSCAD: the nucleus is composed of three protons (in red) and three neutrons (in yellow); the three electrons (in blue) revolve around the nucleus.

In metals, electrons are free to hop away from their nucleus, and move around within the metallic material. When there’s a difference in electrical potential between one end of the metal and another, the electrons flow (at the speed of light) through the material. If you were to connect a battery directly to a piece of metal, the electrons would move at such a high flow rate that the metal (and the battery) would get hot very quickly, and continue to heat until the battery is discharged, or worst case, until the battery or metal catches fire from the heat.

When we speak of electrical phenomena, we have to consider three main physical quantities: current (the flow rate just mentioned), resistance (something that can restrict that flow), and voltage (which we’ll get into shortly).

Current

When you sit on a river bank, you see that water moves downstream from its source to the sea. We associate the term “current” with this movement. Similarly, when you attach a garden hose to a tap, water moves inside the hose and generates a (water) current.

The behavior of an electrical circuit is similar (but not identical; metaphors can only stretch so far). Instead of water molecules flowing through a hose, an electrical circuit has subatomic particles called electrons flowing through a wire. Wires are made of materials, usually metals, that allow the transfer of electrons from one atom to another. Materials of this kind are called conductors, while those that don’t allow electrons to flow are called insulators.

The intensity of the electric current can be compared to the flow rate of a river. In the Nile, the quantity of water flowing in a specific time through a section of the river is much higher than what flows through, say, an irrigation canal. In the same way, the electric current flowing into an electric oven is much higher than the current in a smartphone.

The unit of measurement of electrical current is the ampere (A), from the name of the French André-Marie Ampère, one of the main researchers of electromagnetism. The tool used to measure the strength of an electrical current is the ammeter, shown in Figure 15-3.

Alt Text

Figure 15-3. An analog ammeter

Table 15-1 shows the typical current consumed by some common devices.

Device

Current draw in amps (A)

Train or tram

100 / 500

Oven

10 / 20

Clock radio

1

MP3 player

0.1

Table 15-1. Current used by some devices.

Voltage

Keeping the comparison with water, we see that in nature, water flows only when there is an incline. We also notice that the intensity with which water falls depends on the height of the incline: consider the small inclines we can find in streams and compare them with the Niagara Falls! Voltage can be compared to the incline from which water falls, or to the pressure of water in a pipe.

If we filled up a very long pipe with water and placed it horizontally on the floor, water would come out of the ends, though with little intensity. But if we lifted one end of the pipe, water would come out from the other end at a higher intensity, or, more correctly, with a stronger pressure, and this pressure would increase if the incline were steeper.

The unit of measurement of electrical “pressure”,or voltage, is volt (V), from Alessandro Volta, inventor of the very first batteries and pioneer in the study of electrical currents. The tool used to measure voltage is called voltmeter (Figure 15-4).

Alt Text

Figure 15-4. An analog voltmeter. It doesn’t look too different from the ammeter

Take Care with Electricity

Electricity can kill. Most of the voltages and amperages you’ll use in common maker projects are safe to use, but it doesn’t take a lot of electricity to be dangerous. The effects caused by an electric current crossing your body can include:

§ muscular contractions, paralysis;

§ breathing difficulties;

§ suffocation (can cause death);

§ heart fibrillation (can cause death).

The Occupational Health and Safety Administration’s publication, How Electrical Current Affects the Human Body includes a chart of the dangers as well as the conditions (such as moisture, voltage, and exposure time) that can harm or kill.

Device

Required Operating voltage (V)

Train or tram

3,000

Kitchen oven

2320

Clock radio

12

MP3 player

3

Table 15-2. Different electrical devices require different voltages.

Resistance

Imagine you are watering your flowers with a hose, when suddenly the water flow decreases (Figure 15-5). Someone may have stepped on the hose, thus reducing the cross-section, so water finds it hard to flow through. Electrical resistances are made with materials that make the transit of electrons difficult, similar to the foot on the hose. The resistance is therefore a quantity that measures the blockage of an electrical current. The more the material prevents electrons from passing, the higher the resistance value. Conductors have very low resistance, while insulators are characterized by very high resistance.

Alt Text

Figure 15-5. When you step on a hose, you prevent water from flowing easily.

Resistance is measured in ohms (Ω), named for Georg Simon Ohm, who was the first to identify the directly proportional relation between the resistance applied to a conductor and electrical current: this important relationship is called Ohm’s law.

Just as the resistance in a hose increases if the foot stepping on it is bigger, electrical current increases if the material which electrons must flow through is longer. For each material we can indicate a specific electrical resistance as shown in Table 15-3, which defines how much one meter of material with 1 mm2 cross section opposes the transit of electrons. The specific resistance is measured in ohm/meter (Ω/m). Metals are great conductors, which means they have very low resistance, while air and glass are excellent insulators.

Material

Specific resistance (Ω/m)

Copper

0.0000000169

Iron

0.0000000968

Human body

2,000

Glass

10,000,000,000

Table 15-3. Some examples of specific resistance

Circuits and Components

When we connect different electrical components in a closed path in which the current can continuously flow, we create a circuit.

Circuits

Although the underlying physics is somewhat complex and quite interesting, the flow of electricity in a circuit has enough in common with a hydraulic circuit (Figure 15-6) that we can model their behavior more simply.

Alt Text

Figure 15-6. A simple hydraulic circuit.

The most important rule of an electrical circuit is Kirchhoff’s current law. Simply put, this states that the sum of the currents entering the circuit is equal to the sum of the currents going out of the circuit. (To use the analogy of an hydraulic circuit, this means that all water flowing into the circuit from tap flows out at the other end.) That’s why there are no electrical components with only one terminal: if the current flows into a component, it must also flow out of it, otherwise the circuit won’t work.

Woah, what about an antenna?

An antenna seems to break Kirchhoff’s current law, since it has only one terminal. But an antenna is a case of its own: when an antenna receives a signal, current is induced in the body of the antenna, and it flows out through the antenna terminal, much the same way a rain bucket collects water that falls from the sky and can be drained off through a spigot.

Components

Each type of electronic component has a part number that is used worldwide: a type 2N2222 transistor is a type 2N2222 transistor anywhere you go. Where possible, the code is stamped on the component body using numbers and letters. Where it is not possible (or due to tradition), the code takes the form of notches, grooves, or colored stripes on the body of the component.

For most components, or family of components, manufacturers provide little manuals of instructions for free, called datasheets (see Figure 15-7), with all required information and warnings about how to use the components in the proper way. These datasheets can include electrical parameters, measures and dimensions, warnings, and sometimes even small demonstration circuits.

Alt Text

Figure 15-7. One page of the Transistor 2N2222/D datasheet of the Semiconductor Components Industries, LLC (used with permission from SCILLC dba ON Semiconductor)

Where Do You Get Components?

Up until about the mid-1980s, the United States was dotted with locally owned electrical and electronic repair shops. Throughout the history of electric appliances, when your toaster, radio, TV, hi-fi stereo, or any other electronic equipment broke down, it made economic sense to repair it (or to have it repaired) rather than throw it away. The local repair shop was where you could find new and used electrical components (sometimes painstakingly de-soldered from irreparable machines), as well as someone who knew how to use them. When Radio Shack and other electronic parts retailers began their gigantic expansion at the end of the 1950s, they made electronic components even easier to obtain, and they also were careful to staff their stores with people who could answer your questions about diodes and transistors and such. The 1960s and early 1970s were a golden age of hobby electronics.

Things started to change in the early 1980s. It became cheaper to throw away a broken appliance and buy a new one, rather than have the old one fixed. Neighborhood repair shops started dying. Hobby electronics started dying. Fewer people knew how to solder. Electronic parts stores “rebranded” themselves as electronic gadget stores, and employees who understood resistors and capacitors were few and far between.

Fortunately, on the Internet you can find nearly anything you want. There are a lot of sites from which you can buy loose components. Web stores like Farnell, Element 14, Adafruit, SparkFun, Jameco, Mouser, or DigiKey, sell and ship electronic components around the world. You can also find the datasheets for the components you buy right on these web sites. If you want to purchase kits that contain a collection of parts, Maker Shed, Adafruit, and SparkFun have many choices. Sometimes these collections are an assortment of components that are good to have at the ready, sometimes they are kits for a specific project or purpose.

Of course, in real maker’s style, you can cannibalize your old Christmas gadgets or your children’s or grandchildren’s broken and abandoned toys with just a little patience. You never know what you’ll find, but with some luck you may come across something useful.

Now, let’s have a look at some of the most important components, shown in Figure 15-8 and Figure 15-9.

Alt Text

Figure 15-8. An overview of the main electronic components with corresponding symbols.

Many of the circuit diagrams in this chapter are created with Fritzing, an open source initiative to make it easy to design and manufacture electronic projects.

Alt Text

Figure 15-9. Different types of LED with their corresponding electric symbols.

LED

As we explained earlier, an LED is a diode that emits light. It does this by exploiting a property called electroluminescence, where passing an electric current through certain materials causes them to emit light. Because electroluminescence doesn’t generate heat the way an incandescent bulb does, LEDs generally don’t get perceptibly warm unless the LED is extremely high-power, or unless you put too much current through them.

LEDs usually use a voltage between 1.6 and 3.6 V, and need a current ranging from 20 to 50 milliamps (mA), depending on the specific model of LED you’re using. They are one of the few electronic components that don’t have a code stamped on them, in part because their body is transparent or translucent.

Look very carefully at a standard 5mm LED. Notice that one edge of the LED is blunted so that it is essentially flat instead of curved. That flat spot indicates the cathode, or negative terminal of the LED. The cathode is also distinguished by being shorter than the other terminal--you can remember this as the “minus” terminal because it has something “subtracted” from it.

There are also LEDs that can generate many colors; some multi-color LEDs have three terminals and can generate only red, green, or yellow light (by turning on green and red together). Four-terminal RGB LEDs are also available: three LEDs are contained in a single capsule with which it is possible to generate many colors. What more can we ask for?

Resistors

We can use some components, like the one we used in our first circuit, to resist the current and reduce its flow. These components are resistors (Figure 15-10), which are small, cylindrical objects, vaguely the size of a large grain of rice.

Alt Text

Figure 15-10. A resistor

Resistors have colored bands or rings printed on them. The specific colors, in specific order, specify the resistance value of the resistor. The code seems complicated at first, but it’s not very difficult to pick up: at one end of the resistor there is a band indicating the tolerance, i.e. how precise the resistance value is: if it is gold, its value is 5%, if silver it is 10%. When you read the resistance, keep this last band on the right: from left to right, each color corresponds to a number.

Color

Numbers

Black

0

Brown

1

Red

2

Orange

3

Yellow

4

Green

5

Blue

6

Violet

7

Grey

8

White

9

Table 15-4.Resistor color codes

Starting from the left, look at the first two bands and note down the corresponding number; the third band indicates how many zeros to append to the first two numbers to obtain the actual value of the resistor. In our first example (Figure 15-1) we used a resistor with orange, white and brown bands (the last band, the golden or silver one, does not interest factor into the value calculation). Orange corresponds to 3, white to 9 and brown to 1, so we’ll write the number 39 followed by one 0: the resistance value is 390 ohms.

What happens if you link two resistors, one after the other? Think back to the example of the hose with the foot stepping on it. If you step on the hose with both feet, you will not get just one, but two obstructions, resulting in a higher resistance. When you apply this principle to electronic components, this is called a connection in series and the resulting resistance is the sum of the single resistors:

Rtotal = R1 + R2

In Figure 15-11, you see two resistors, one with red (2), red(2), and brown (1 zero), giving 220 ohms; the other with brown (1), black (0), and red (2 zeros), giving 1,000 ohms or 1 kilohm (abbreviated 1K). Together they give 1,220 ohms.

Alt Text

Figure 15-11. The values of resistances linked in series must be added to one another.

You can link two resistors in a different way too, by coupling their terminals together. In this way the total resistance is calculated with the following formula:

Rtotal = (R1 * R2) / (R1 + R2)

It is easy to verify that the resulting resistance decreases. In particular, in case the two resistances R1 and R2 are equal, the resulting resistance is equal to half of the single resistances’ value. We add resistances but the total resistance decreases. So in Figure 15-12, the resistance is only 500:

(1,000 * 1,000) / (1,000 + 1,000) = 1,000,000 / 2,000 = 500

Alt Text

Figure 15-12. Two parallel resistances

The resistors used in electronic circuits can vary from tens of ohms up to millions of ohms. Resistors having a higher value obstruct the flowing current more.

When a rope runs through our hands too quickly, we risk getting serious burns from friction. Similarly, when current flows through a resistor, it also produces heat, and excessive heat risks damaging the components of our circuit. Resistors must not be chosen randomly; you need to use the right resistors for each circuit. You’ll see how to choose the right ones in “Ohm’s Law”.

Trimmers and Potentiometers

There are variable resistors whose value can be set by turning a control knob, just like you do with water taps, in which a valve widens or shrinks the diameter an obstruction and lets more or less water flow through. There are two types, shown in Figure 15-13:

§ you will use a potentiometer if you have to frequently change the resistance value, for example, when you turn up or down the volume control of an old fashioned audio system.

§ trimmers have no control knob; they are set with a screwdriver and are used when you have to change the value rarely, for example on light sensors.

Alt Text

Figure 15-13. A potentiometer and a trimmer with their electrical symbol.

Both have two or three terminals, or clips, and they can be used in two different ways (Figure 15-14):

§ as a variable resistor: you connect them so that only two pins are used;

§ as a voltage divider: you connect all three pins and the voltage on the second pin varies based on where you’ve positioned the knob or the screw. See “Using a Voltage Divider” for more details.

Using a Voltage Divider

This involves different math than the earlier calculation where you read the total value of resistors in series. With a voltage divider, you calculate the voltage produced by looking at the input voltage, the value of the resistor closest to the positive terminal (R1), and the value of the resistor closest to the negative terminal (R2). When you turn the knob or screw such that the resistance of R1increases, R2 decreases accordingly. The terminal with the input voltage is labeled Vcc in Figure 15-14, and the output voltage as Va. The terminal marked GND is connected to ground (negative).

Va = Vcc * ( R2 / ( R1 + R2 )

Alt Text

Figure 15-14. The two possible ways of using a potentiometer.

Capacitors

You can think of a capacitor as similar to a cistern in which you store small quantities of water. The capacitors’ capacity is measured in farads (F). Typical values range from the microfarads (µF, 0.000001F farad), for the components used in chargers or audio amplifiers, to the picofarads (pF, 0.000000000001F farad) of radio or computer components.

If you were to create a capacitor you’d make a sort of a sandwich with two layers of conductive material padded with an insulating layer (or with air) so that the current has an incredibly difficult time passing through. As insulating material you’d use ceramic, plastic, paper, liquids, and certain metals. For this reason it is possible to find capacitors in different shapes and sizes, as shown in Figure 15-15. Because of the materials used for their manufacturing, some kinds of capacitors, like electrolytic capacitors, also have a polarity; one side is positive, the other side is negative.

Alt Text

Figure 15-15. Some capacitors and their corresponding symbol.

What would happen if you tried to add a capacitor of some hundreds of µF to the Hello World circuit? Figure 15-16 shows what it would look like.

Alt Text

Figure 15-16. -The Hello World circuit modified by adding a capacitor.

The LED lights up, but only for a fraction of second, and it turns off again straight away. How is this possible? Capacitors only permit alternating current to pass through. If you disconnected the capacitor and you connected it directly, but inverted, to the LED pins (Figure 15-17), the LED would light up again for a short moment, thus stealing away the energy stored by the capacitor.

Alt Text

Figure 15-17. By disconnecting the battery and connecting the capacitor, inverted, you discharge it.

Diodes

A wire and a resistor both let current flow in either direction. It doesn’t matter how you orient these components in your circuit. As we mentioned earlier, a diode (Figure 15-18) is a component which lets current flow easily in only one direction. They are used to prevent current from flowing in the wrong direction to protect certain components, which would otherwise be damaged by allowing current to flow through them. In our comparison with water, a diode is like a non-return valve, which lets water flow through in one direction only.

Alt Text

Figure 15-18. A diode and its symbol.

Buttons and Switches

One of the simplest ways to let people interact with an artifact is to make them press a button. A button is a switch--a mechanical device that completes a circuit, letting electricity flow, or breaks a circuit, stopping the flow. There are two types of buttons:

§ normally open buttons, which (untouched) prevent the current from flowing; when you press them, you close the circuit and the current can flow through;

§ normally closed buttons, which (untouched) let the current flow through; when you press them, you open the circuit and stop the current from flowing.

Switches work in a similar way, but stay in the position you put them in. Pushbuttons are commonly momentary; their actions are only in effect while you are pressing the button. A switch is a toggle--if you turn a switch off, it stays off until you turn it back on again. Our homes are full of switches: we use them to turn lights on and off.

Alt Text

Figure 15-19. A button and a toggle switch with their corresponding symbols.

Tools

First of all, to work in a comfortable way, you need a well-lit working surface. If you use a table it is better to cover it with a plywood or thick cardboard layer to protect its surface. The tools needed to start building small circuits are few and they are not expensive. At first a pocket knife, a pair of scissors, and a screwdriver can be more than enough. However, as the circuits get more complex, to do a good job you will need suitable tools, shown in Figure 15-20. The more adequate and good quality they are, the better the result and the lower your strain.

Alt Text

Figure 15-20. A minimum set of tools.

The basic tools are screwdrivers, tweezers, electrician’s scissors, clippers, wire stripper, a multimeter (see “Measurements”), and, maybe, a magnifying lens. After the very first experiments you will need a soldering iron and solder, a desoldering pump, a sponge for the soldering tip, and finally a “third hand” device to help you hold the components. Figure 15-21 shows these.

Alt Text

Figure 15-21. The necessary kit

Although it is possible to work with batteries, it is always better to have a power supply in order to have a stable and reliable supply voltage. Professional labs are equipped with different power supplies in terms of voltage and current, able to support any circuit. For the simplest experiments you can make do with some power supplies found at home, like the charger of an old mobile phone.

Creating a circuit

Figure 15-22 shows the ways that wires may be represented in a circuit diagram (schematic) From left to right, the first two are used to indicate when wires cross in the diagram but shouldn’t be connected together (sometimes, it’s not possible to draw the lines any way aside from overlapping). The last shows wires that must be connected.

Alt Text

Figure 15-22. Wires crossing in a circuit: only in the third case the wires are in contact.

The circuit diagram has usually little to do with the final circuit for a series of reasons: the pins of a component may be in a different order from the symbol, the diagram does not consider the actual dimensions of the components and so on.

How do you make an electronic circuit? The quickest, simplest and least risky way is to use a prototyping breadboard (Figure 15-23), so called because it looks like a bread cutting board composed of a pierced grid on a tray: when bread is cut, crumbs fall through the holes and are collected in the tray.

Alt Text

Figure 15-23. A breadboard.

Using a breadboard is a little like playing with Lego building blocks: components are inserted into little sockets. Unlike with Legos, they are then linked with wire. You can use simple solid core wires or wires called jumpers equipped with handy connectors on their ends (Figure 15-24).

Alt Text

Figure 15-24. Jumpers for the links on a breadboard.

Breadboards are almost always divided into left and right sectors, with a non-conductive “gutter” running between and separating them. The sockets of each half line are all electrically linked, row by row, as shown in Figure 15-25 and Figure 15-26.

Alt Text

Figure 15-25. The half lines of a breadboard are like many T-joints linked together.

Alt Text

Figure 15-26. All sockets of a half line are linked to one another.

Breadboards are very practical and quick, but using them for anything other then the absolutely simplest circuits does tend to lead to a tangle of wires and unstable situations. Therefore, it is extremely important to try to be tidy and find an optimal arrangement of the components.

Some Tips on How to Arrange the Breadboard

The biggest breadboards usually have two pairs of side lines called rails used to bring electricity to the board. Rails are more or less at the same distance from all components and prevent tangles from developing. You can place jumper wires across them to share the voltage with both sets of rails as shown in Figure 15-27.

Alt Text

Figure 15-27. A breadboard with the rails of both sides linked together.

If the circuit requires a double power supply, for example with 5 and 12 volts, it is better to dedicate one rail to 5 V and the other to 12 V. The wires of the negative pole of the power supply (sometimes called “ground” or GND), must always be linked with one another. To minimize electrical interference, add 100 nF capacitors directly onto the rails as shown in Figure 15-28.

Alt Text

Figure 15-28. Two different voltages, masses linked to one another, capacitors to diminish disturbances

On some breadboards, the rails are divided in half, so it is necessary to link them with a small U-shaped piece of wire.

Avoid rings and spirals of wire: if the circuit is particularly delicate or sensitive those loops may behave like the antennas of a radio, which is not always (i.e. hardly ever) what you want because it can cause unpredictable behavior in your circuit, and may emit undesirable radio emissions. Try to use only wires of precisely the right length. Assemble everything with care without overlapping the links.

You can’t put all the components in any order or position you like on a breadboard. They must connect to each other the way the circuit design commands. Potentiometers, speakers, relays, and charging plugs can be adapted by soldering or linking wires to their terminals.

If we want a more solid and resistant circuit we can use a soldering iron to fix the components to some pierced plates called matrix boards, or even create a PCB (Printed Circuit Board). Figure 15-29 and Figure 15-30 show both types.

Alt Text

Figure 15-29. A prototype

Alt Text

Figure 15-30. The ABNormal board on PCB.

Measurements

Earlier, you saw that current and voltage are measured with similar-looking tools. Someone had the great idea to create a tool able to measure both quantities, as well as other electric quantities: the multimeter. Both digital and analog multimeters are available: the analog ones, which show values via needles, are still very popular because they measure the signals directly. Digital multimeters, on the other hand, indicate measurements with numbers on an LCD display; fluctuation in the signal shows up as wildly varying values on the display screen.

A multimeter is equipped with a pair of inputs, usually a red and a black wire with pen-like probes attached to the ends. The black probe reads the common or ground signal (represented as COM or GND). The red probe reads the quantity we want to measure: voltage, resistance, or amperage, which is usually selected by turning a control knob, as shown in Figure 15-31.

Alt Text

Figure 15-31. A multimeter control knob set to test a diode.

A simple quantity to measure is voltage. Make sure the probes are inserted in the correct socket on the multimeter: the black probe in the COM socket and the red probe in the V or DCV socket. Turn the control knob to an appropriate DCV position: the voltage you measure must be lower to the one set than the labelled setting on the multimeter: If you’re measure something around 7 volts, set the control knob to 10 or 20 volts. If you are unsure, start with the highest setting, and work your way down. To measure the voltage between two points of the circuit, simply touch the probes to exposed conductors (either exposed wire, or exposed component pins) on the part of the circuit you are interested in, as shown in Figure 15-32.

AC/DC

You need to know whether you’re measuring AC or DC voltage. The probe wire goes into a different jack on the multimeter when measuring AC, and most AC voltages you’ll encounter are life-threatening. You can seriously damage your multimeter (not to mention yourself) if you mess this up.

Alt Text

Figure 15-32. How to measure the voltage at the ends of a resistor.

You can also measure the amperage flowing through part of a circuit. As with measuring the voltage, set the control knob to the appropriate setting for the current you’re measuring. Unlike with voltage, you need to “break” the circuit where you want to measure and place the meter across the break, as shown in Figure 15-33. The value registered by the multimeter is the intensity of the current that flows through this point in the circuit.

Alt Text

Figure 15-33. How to measure the current flowing through a resistor.

Ohm’s Law

Many components you use in your circuits work only if you supply the right voltage. Continuing the metaphor that voltage is much like water pressure, it’s a bit like making the wheel of a mill turn. If you placed the mill wheel under Niagara Falls, it would be destroyed immediately; the pressure would be too high for it. If you tried to make the mill wheel turn with the stream from a kitchen tap, it wouldn’t move at all.

Current, voltage and resistance are not independent quantities, but, as we said before, they are linked by Ohm’s law:

V = R * I

V is voltage, I is current intensity, and R is resistance. This law is extremely important because it allows you to make the necessary calculations to protect your circuits. You will know what voltage and what resistors you have to supply your circuits with so that everything will work perfectly and nothing is damaged.

Let’s go back to the blinking LED version of HelloWorld. Have we chosen the right resistor?

To work correctly, the LED requires a precise voltage and a certain quantity of current, both of which you can obtain from a datasheet. Usually, the charging supply voltage depends on the color and the type of LED, while the working current ranges from 10 to 20 mA.

LED color

Supply Charging voltage (V)

Red

1.8

Yellow

1.9

Green

2.0

Orange

2.0

Blue/White

3.0

Blue

3.5

Table 15-5. Typical values for the supply charging voltages of LEDs.

Suppose you are using a 9 volt battery and an orange LED: if you linked them directly, the LED would get burnt (just like the wheel of a small mill would break under Niagara Falls). If you need 2 volts for the LED, a 9 volt battery supplies 7 volts too many. What do we do?

This is why we need a resistor: we are going to use it to divide the waterfall into two smaller falls so that the second one has a suitable height for our mill (Figure 15-34). The waterfalls are shown as arrows. The arrows length is equal to the water drop. The first arrow, on the left, represents the battery and it is 9 units long. We then draw two more arrows on the left (of 7 and 2 volts). The loop must be always closed and we must have a balance between what we have on the right and on the left: this is just a graphic representation of Kirchhoff’s current law. What resistance do we need in order to get the 7 volt voltage needed not to break our LED?

Alt Text

Figure 15-34. Split the waterfall into two small waterfalls

With some mathematics you can write Ohm’s law as follows:

R = V/I

We have said that you need to divert 7 volts. From the LED datasheet we know that 20 mA, i.e. 0.020 A, must flow through the LED. So, if you replace the values in the equation we get:

R = 7V / 0.020 A = 350 Ω

We will not find a 350 ohm resistor on the market, because they are manufactured with standard values, but we can come very close: the nearest standard is 348 ohms! While this will be acceptable for most purposes, it is always better to reduce the current a bit too much than to put too much current through a device. When faced with this situation, while we can use a 348 ohm resistor, we should probably use the next one higher, which would be a 360 ohm resistor, or even a 390.

Ohm’s law also explains to us why we have to avoid short circuits: in a short circuit the resistance is practically zero. If we write again Ohm’s law again, this time as follows:

I = V / R

it is easy to see that in a short circuit with practically zero resistance, we are dividing the voltage by a very small number, so the current will tend toward an infinite a very high value. Our power source will do its best to try to supply it, but at a certain point it will reach its limit and something will break. Even with “just” a 12V car battery, a big screwdriver placed across the terminals can get (partly) disintegrated and harm the unlucky human who put it there!