Table of Contents
Preface xi
1 Theory 1
1.0 Introduction 1
1.1 Understanding Current 1
1.2 Understanding Voltage 2
1.3 Calculate Voltage, Current or Resistance 4
1.4 Calculate Current at Any Point in a Circuit 6
1.5 Calculate the Voltages Within Your Circuit 7
1.6 Understanding Power 8
1.7 Alternating Current 8
2 Resistors 11
2.0 Introduction 11
2.1 Read Resistor Packages 11
2.2 Find Standard Resistor Values 14
2.3 Select a Variable Resistor 15
2.4 Combine Resistors in Series 17
2.5 Combine Resistors in Parallel 18
2.6 Reduce a Voltage to a Measurable Level 19
2.7 Choose a Resistor that Won't Burn Out 21
2.8 Measure Light Levels 22
2.9 Measure Temperature 23
2.10 Choose the Right Wires 24
3 Capacitors and Inductors 29
3.0 Introduction 29
3.1 Store Energy Temporarily in Your Circuits 29
3.2 Identify Types of Capacitors 33
3.3 Read Capacitor Packages 35
3.4 Connect Capacitors in Parallel 36
3.5 Connect Capacitors in Series 37
3.6 Store Huge Amounts of Energy 38
3.7 Calculate the Energy Stored in a Capacitor 39
3.8 Modify and Moderate Current Flow 40
3.9 Convert AC Voltages 41
4 Diodes 45
4.0 Introduction 45
4.1 Block the Flow of Current in One Direction 45
4.2 Know Your Diodes 47
4.3 Use a Diode to Restrict DC Voltages 49
4.4 Let There Be Light 50
4.5 Detect Light 52
5 Transistors and Integrated Circuits 55
5.0 Introduction 55
5.1 Switch a Stronger Current Using a Weaker One 56
5.2 Switch a Current with Minimal Control Current 59
5.3 Switch High Current Loads Efficiently 61
5.4 Switch Very High Voltages 63
5.5 Choosing the Right Transistor 64
5.6 Switching Alternating Current 67
5.7 Detecting Light with Transistors 68
5.8 Isolating Signals for Safety or Noise Elimination 69
5.9 Discover Integrated Circuits 71
6 Switches and Relays 73
6.0 Introduction 73
6.1 Switch Electricity Mechanically 73
6.2 Know Your Switches 75
6.3 Switching Using Magnetism 77
6.4 Rediscover Relays 78
7 Power Supplies 81
7.0 Introduction 81
7.1 Convert AC to AC 82
7.2 Convert AC to DC (Quick and Dirty) 83
7.3 Convert AC to DC with Less Ripple 85
7.4 Convert AC to Regulated DC 87
7.5 Converting AC to Variable DC 89
7.6 Regulate Voltage from a Battery Source 90
7.7 Make a Constant-Current Power Supply 91
7.8 Regulate DC Voltage Efficiently 92
7.9 Convert a Lower DC Voltage to a Higher DC Voltage 93
7.10 Convert DC to AC 94
7.11 Power a Project from 110 or 220V AC 97
7.12 Multiply Your Voltage 98
7.13 Supply High Voltage at 450V 99
7.14 Even Higher Voltage Supply (>1kV) 102
7.15 Very Very High Voltage Supply (Solid-State Tesla Coil) 103
7.16 Blow a Fuse 106
7.17 Protect from Polarity Errors 107
8 Batteries 111
8.0 Introduction 111
8.1 Estimating Battery Life 111
8.2 Selecting a Nonrechargeable Battery 113
8.3 Selecting a Rechargeable Battery 115
8.4 Trickle Charging 116
8.5 Automatic Battery Backup 117
8.6 Charging LiPo Batteries 119
8.7 Get Every Drop of Power with the Joule Thief 120
9 Solar Power 123
9.0 Introduction 123
9.1 Power Your Projects with Solar 123
9.2 Choose a Solar Panel 126
9.3 Measure the Actual Output Power of a Solar Panel 128
9.4 Power an Arduino with Solar 130
9.5 Power a Raspberry Pi with Solar 132
10 Arduino and Raspberry Pi 135
10.0 Introduction 135
10.1 Explore Arduino 135
10.2 Downloading and Using the Book's Arduino Sketches 139
10.3 Explore Raspberry Pi 140
10.4 Downloading and Running This Books Python Programs 141
10.5 Run a Program on Your Raspberry Pi on Startup 142
10.6 Explore Alternatives to Arduino and Raspberry Pi 143
10.7 Switch Things On and Off 145
10.8 Control Digital Outputs with Arduino 149
10.9 Control Digital Outputs from Raspberry Pi 150
10.10 Connect Arduino to Digital Inputs Like Switches 151
10.11 Connect Raspberry Pi to Digital Inputs Like Switches 154
10.12 Read Analog Inputs on Arduino 155
10.13 Generate Analog Output on Arduino 157
10.14 Generate Analog Output on Raspberry Pi 160
10.15 Connect Raspberry Pi to I2C Devices 162
10.16 Connect Raspberry Pi to SPI Devices 164
10.17 Level Conversion 165
11 Switching 169
11.0 Introduction 169
11.1 Switch More Power than Your Pi or Arduino Can Handle 169
11.2 Switch Power On the High Side 171
11.3 Switch Much More Power 173
11.4 Switch Much More Power on the High Side 175
11.5 Choose Between a BJT and MOSFET 176
11.6 Switch with Arduino 178
11.7 Switch with a Raspberry Pi 181
11.8 Reversible Switching 183
11.9 Control a Relay from a GPIO Pin 184
11.10 Control a Solid-State Relay from a GPIO Pin 187
11.11 Connect to Open-Collector Outputs 188
12 Sensors 191
12.0 Introduction 191
12.1 Connect a Switch to an Arduino or Raspberry Pi 191
12.2 Sense Rotational Position 196
12.3 Sense Analog Input from Resistive Sensors 201
12.4 Add Analog Inputs to Raspberry Pi 203
12.5 Connect Resistive Sensors to the Raspberry Pi without an ADC 204
12.6 Measure Light Intensity 206
12.7 Measure Temperature on Arduino or Raspberry Pi 207
12.8 Measure Temperature without an ADC on the Raspberry Pi 209
12.9 Measure Rotation Using a Potentiometer 211
12.10 Measure Temperature with an Analog IC 212
12.11 Measure Temperature with a Digital IC 214
12.12 Measure Humidity 218
12.13 Measure Distance 220
13 Motors 225
13.0 Introduction 225
13.1 Switch DC Motors On and Off 226
13.2 Measure the Speed of a DC Motor 227
13.3 Control the Direction of a DC Motor 229
13.4 Setting Motors to Precise Positions 233
13.5 Move a Motor a Precise Number of Steps 238
13.6 Choose a Simpler Stepper Motor 243
14 LEDs and Displays 249
14.0 Introduction 249
14.1 Connect Standard LEDs 249
14.2 Drive High-Power LEDs 252
14.3 Power Lots of LEDs 254
14.4 Switch Lots of LEDs at the Same Time 256
14.5 Multiplex Signals to 7-Segment Displays 256
14.6 Control Many LEDs 259
14.7 Change the Colors of RGB LEDs 264
14.8 Connect to Addressable LED Strips 268
14.9 Use an I2C 7-Segment LED Display 271
14.10 Display Graphics or Text on OLED Displays 275
14.11 Display Text on Alphanumeric LCD Displays 277
15 Digital ICs 281
15.0 Introduction 281
15.1 Protecting ICs from Electrical Noise 281
15.2 Know Your Logic Families 283
15.3 Control More Outputs Than You Have GPIO Pins 284
15.4 Build a Digital Toggle Switch 288
15.5 Reduce a Signal's Frequency 289
15.6 Connect to Decimal Counters 290
16 Analog 293
16.0 Introduction 293
16.1 Filter Out High Frequencies (Quick and Dirty) 293
16.2 Create an Oscillator 297
16.3 Flash LEDs in Series 298
16.4 Avoid Drops in Voltage from Input to Output 299
16.5 Build a Low-Cost Oscillator 301
16.6 Build a Variable Duty Cycle Oscillator 303
16.7 Make a One-Shot Timer 305
16.8 Control Motor Speed 306
16.9 Apply PWM to an Analog Signal 308
16.10 Make a Voltage-Controlled Oscillator (VCO) 310
16.11 Explore Decibel Measurement 311
17 Operational Amplifiers 315
17.0 Introduction 315
17.1 Select an Op-Amp 316
17.2 Power an Op-Amp (Split Supply) 318
17.3 Power an. Op-Amp (Single Supply) 319
17.4 Make an Inverting Amplifier 320
17.5 Make a Noninverting Amplifier 322
17.6 Buffer a Signal 323
17.7 Reduce the Amplitude of High Frequencies 325
17.8 Filter Out Low Frequencies 328
17.9 Filter Out High and Low Frequencies 330
17.10 Compare Two Voltages 332
18 Audio 335
18.0 Introduction 335
18.1 Play Sounds on an Arduino 336
18.2 Play Sound with a Raspberry Pi 339
18.3 Incorporate an Electret Microphone Into a Project 340
18.4 Make a 1W Power Amplifier 343
18.5 Make a 10W Power Amplifier 345
19 Radio Frequency 349
19.0 Introduction 349
19.1 Make an FM Radio Transmitter 354
19.2 Create a Software FM Transmitter Using Raspberry Pi 355
19.3 Build an Arduino-Powered FM Receiver 357
19.4 Send Digital Data Over a Radio 359
20 Construction 365
20.0 Introduction 365
20.1 Create Temporary Circuits 365
20.2 Create Permanent Circuits 372
20.3 Design Your Own Circuit Board 375
20.4 Explore Through-Hole Soldering 378
20.5 Explore Surface-Mount Soldering 379
20.6 Desolder Components 384
20.7 Solder Without Destroying Components 385
21 Tools 389
21.0 Introduction 389
21.1 Use a Lab Power Supply 389
21.2 Measure DC Voltage 391
21.3 Measure AC Voltage 392
21.4 Measure Current 393
21.5 Measure Continuity 394
21.6 Measure Resistance, Capacitance, or Inductance 395
21.7 Discharge Capacitors 396
21.8 Measure High Voltages 397
21.9 Use an Oscilloscope 400
21.10 Use a Function Generator 402
21.11 Simulation 403
21.12 Working Safely with High Voltages 406
A Parts and Suppliers 409
B Arduino Pinouts 419
C Raspberry Pi Pinouts 421
D Units and Prefixes 423
Index 425