HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
ARDUINO for BEGINNERS
ESSENTIAL SKILLS EVERY MAKER NEEDS
Loaded with full-color step-by-step illustrations!
Absolutely no experience needed!
Learn Arduino from the ground up, hands-on, in full color!
Discover Arduino, join the DIY movement, and build an amazing spectrum of projects… limited only by your imagination!
No “geekitude” needed: This full-color guide assumes you know nothing about Arduino or programming with the Arduino IDE. John Baichtal is an expert on getting newcomers up to speed with DIY hardware. First, he guides you gently up the learning curve, teaching you all you need to know about Arduino boards, basic electronics, safety, tools, soldering, and a whole lot more. Then, you walk step-by-step through projects that reveal Arduino’s incredible potential for sensing and controlling the environment–projects that inspire you to create, invent, and build the future!
· Use breadboards to quickly create circuits without soldering
· Create a laser/infrared trip beam to protect your home from intruders
· Use Bluetooth wireless connections and XBee to build doorbells and more
· Write useful, reliable Arduino programs from scratch
· Use Arduino’s ultrasonic, temperature, flex, and light sensors
· Build projects that react to a changing environment
· Create your own plant-watering robot
· Control DC motors, servos, and stepper motors
· Create projects that keep track of time
· Safely control high-voltage circuits
· Harvest useful parts from junk electronics
· Build pro-quality enclosures that fit comfortably in your home
Introduction 1
Chapter 1 Arduino Cram Session ................................................ 5
Arduino Uno: A Rookie-Friendly Microcontroller ............................5
Other Arduino Products ................................................................8
Electronics ....................................................................................9
Light-Emitting Diodes ..............................................................11
Buttons and Switches ...............................................................11
Potentiometers ........................................................................12
Resistors ..................................................................................13
Capacitors ...............................................................................14
Motors ....................................................................................15
Solenoids .................................................................................16
Piezo Buzzers ...........................................................................17
Seven-Segment Displays ...........................................................18
Relays ......................................................................................19
Integrated Circuits ...................................................................20
Temperature Sensors ................................................................21
Flex Sensor...............................................................................22
Light Sensor .............................................................................23
Ultrasonic Sensor .....................................................................23
Safety Rules .................................................................................24
The Next Chapter ........................................................................26
Chapter 2 Breadboarding ......................................................... 27
Assembling Circuits Using Solderless Breadboards .......................27
Understanding Power and Ground ...........................................30
Using Jumper Wires .................................................................30
Project: Breadboard Blink ............................................................32
Project: Laser Trip Beam ..............................................................35
Assembling the Laser Module ...................................................38
Assembling the Sensor Module .................................................38
Building the Enclosures ............................................................41
Laser Trip Beam Code ..............................................................47
Setting Up the Trip Beam .........................................................49
Alt.Project: Infrared Detector .......................................................50
Wiring Up the PIR and Buzzer ..................................................51
Infrared Detector Code ............................................................51
The Next Chapter ........................................................................52
Chapter 3 How to Solder ......................................................... 53
Gathering Soldering Supplies .......................................................55
Picking a Soldering Iron............................................................55
Choosing a Solder ....................................................................58
Getting the Other Things You Need ..........................................59
Desktop Vises ...............................................................................59
Cutters and Strippers .....................................................................60
Needle-Nose Pliers and Hemostats ..................................................61
Fans or Fume Extractors .................................................................62
ESD Protection .............................................................................62
Solder Stand and Sponge ................................................................63
Soldering .....................................................................................64
Desoldering .................................................................................68
Cleanup ......................................................................................71
Project: LED Strip Coffee Table ....................................................72
Preparing the Light Strip ..........................................................73
Attaching the Light Strip to the Table .......................................75
Building the Enclosure .................................................................76
Controlling the LED Strip .........................................................82
LED Strip Code ...........................................................................82
The Next Chapter ........................................................................90
Chapter 4 Setting Up Wireless Connections ............................... 91
XBee Wireless Modules ................................................................92
XBee Versus XBee Pro ..............................................................92
Series 1 Versus Series 2 ............................................................93
XBee Breakout Boards .................................................................93
Anatomy of the XBee ...................................................................94
Competing Wireless Modules.......................................................95
Freakduino Chibi .....................................................................95
JeeLabs JeeNode .......................................................................96
Project: Wireless LED Activation ..................................................96
Wireless LED Code ......................................................................99
Project: Bluetooth Doorbell .......................................................101
The Button ............................................................................103
Instructions for Wiring Up the Doorbell ..................................103
Button Unit ................................................................................103
Buzzer Unit ................................................................................105
Building the Doorbell Enclosures ............................................107
Button Unit Enclosure ..................................................................108
Bending Acrylic ...........................................................................109
Buzzer Unit Enclosure ..................................................................112
Wireless Doorbell Code .............................................................112
Button Unit Code ..................................................................113
Buzzer Unit Code ...................................................................114
The Next Chapter ......................................................................115
Chapter 5 Programming Arduino ............................................. 117
The Arduino Development Environment .....................................118
Programming Window ..........................................................118
Menus ...................................................................................120
File Menu ...................................................................................120
Edit Menu ..................................................................................120
Sketch Menu...............................................................................121
Tools Menu ................................................................................122
Help Menu .................................................................................123
The Blink Sketch ........................................................................124
Learning from Example Code .....................................................127
Adapt the Code .....................................................................128
Finding Example Code ............................................................128
Arduino Playground .....................................................................129
Libraries.....................................................................................130
Sharing Example Code .................................................................131
More Functions and Syntax........................................................133
Arithmetic ..............................................................................133
Arrays ....................................................................................133
Comparison Operators ..........................................................134
For ........................................................................................134
Include ..................................................................................135
Increment/Decrement ............................................................135
Interrupts ..............................................................................135
If/Else ....................................................................................136
Mapping ................................................................................136
Random.................................................................................136
Switch/Case ...........................................................................137
While .....................................................................................137
Debugging Using the Serial Monitor ..........................................137
All About Libraries.....................................................................139
Resources for Learning Programming .........................................141
Books ....................................................................................141
Websites ................................................................................141
The Next Chapter ......................................................................141
Chapter 6 Sensing the World ................................................. 143
Lesson: Sensors .........................................................................144
Digital Versus Analog .............................................................145
Digital .......................................................................................145
Analog .......................................................................................145
Connecting Digital and Analog Sensors ..................................146
Know Your Sensors ....................................................................146
Accelerometer ........................................................................147
Barometric .............................................................................147
Encoder .................................................................................148
Gas ........................................................................................148
Hall Effect ..............................................................................149
Infrared .................................................................................150
Piezo Buzzer (Knock Sensor) ..................................................150
Sound Sensors .......................................................................151
Tilt Sensors ............................................................................151
Project: Mood Light...................................................................152
Instructions............................................................................154
Mood Lamp Code ..................................................................159
Alt.Project: Kerf Bending ...........................................................162
The Next Chapter ......................................................................163
Chapter 7 Controlling Liquid ................................................... 165
Lesson: Controlling the Flow of Liquid .......................................166
Solenoid Valve .......................................................................166
Pressurized Reservoir ..............................................................167
Peristaltic Pump .....................................................................168
Mini Project: Make a Pressurized Reservoir ................................169
Instructions............................................................................170
Pressurized Reservoir Code .....................................................171
Project: Plant-Watering Robot ...................................................173
Instructions............................................................................175
Plant-Watering Robot Electronics ...........................................179
Plant-Watering Robot Enclosure ............................................181
Adding the Electronics ..................................................................182
Plant-Watering Robot Code ...................................................185
The Next Chapter ......................................................................186
Chapter 8 Tool Bin ................................................................ 187
Maker’s Ultimate Toolbox .........................................................188
Basic Multimeter ....................................................................188
Multitool ...............................................................................189
Measuring Tape .....................................................................190
Soldering Iron .......................................................................190
Digital Caliper ........................................................................191
Scissors..................................................................................192
X-Acto Knives .........................................................................192
Screwdrivers ...........................................................................193
Hardware...............................................................................193
Wire Strippers ........................................................................194
Super Glue .............................................................................195
Mini Flashlight .......................................................................196
Hot Glue Gun ........................................................................196
Magnifying Glass ....................................................................197
Writing Supplies.....................................................................197
Sketchbook ............................................................................198
Charging Cables .....................................................................198
Working with Wood ..................................................................200
Laser Cutter ...........................................................................200
How to Use a Laser Cutter ...........................................................201
Rotary Tool ...........................................................................202
Air Compressor and Attachments ...........................................203
Drill .......................................................................................203
CNC Mill ...............................................................................204
Lasering and CNCing Services .......................................................205
Table Saw ..............................................................................206
Lathe .....................................................................................206
Sander ...................................................................................207
Working with Plastic ..................................................................208
3D Printers ............................................................................209
LEGO ....................................................................................210
Sugru .....................................................................................211
Vacuum Former .....................................................................211
Extruder .................................................................................212
Tamiya ..................................................................................213
Working with Metal ...................................................................214
Plasma Cutter ........................................................................215
Band Saw ..............................................................................216
Grinder ..................................................................................217
Welder ...................................................................................218
Aluminum Building Systems ...................................................219
80/20 .......................................................................................219
MicroRAX ..................................................................................220
OpenBeam .................................................................................221
Makeblock .................................................................................222
VEX ...........................................................................................223
Maker Spaces ............................................................................224
Software....................................................................................228
GIMP .....................................................................................228
Inkscape ................................................................................229
Fritzing ..................................................................................230
KiCad PCB Layout Software ...................................................230
MakerCase .............................................................................231
Electronics Tools and Techniques ..............................................232
Multimeters ...........................................................................233
Harvesting Electronics ............................................................235
Electronics Marking ...............................................................238
Part Numbers .............................................................................238
Datasheets .................................................................................239
Resistor Color Bands ...................................................................240
Schematic Symbols ................................................................241
The Next Chapter ......................................................................242
Chapter 9 Ultrasonic Detection ............................................... 243
Lesson: Ultrasonic Detection .....................................................244
Ultrasonic Sensor Applications ...............................................245
Mini Project: Make an Ultrasonic Night Light .............................245
Ultrasonic Night Light Code ...................................................246
Project: Cat Toy ........................................................................247
Instructions............................................................................250
Enclosure ..............................................................................252
Lathe 101 ..................................................................................269
Lathe Safety ..............................................................................271
The Next Chapter ......................................................................272
Chapter 10 Making Noise ...................................................... 273
Noise in Electronics ...................................................................274
Thingamagoop .......................................................................275
Tactile Metronome .................................................................275
LushOne Synth.......................................................................276
Mini Project: Pushbutton Melody ...............................................278
Instructions............................................................................279
Pushbutton Melody Code .......................................................280
Project: Noisemaker ..................................................................282
Instructions............................................................................283
Noisemaker Code...................................................................293
The Next Chapter ......................................................................294
Chapter 11 Measuring Time ................................................... 295
Time Server ............................................................................295
Arduino’s Timer ....................................................................296
Real-Time Clock (RTC) Module ..............................................297
Mini Project: Digital Clock .........................................................298
Instructions............................................................................300
Digital Clock Code .................................................................301
Project: Indoor Wind Chime ......................................................302
Servo Horns ...........................................................................303
Instructions............................................................................304
Code .....................................................................................316
Computer Numerically Controlled (CNC) Tools .........................318
The Next Chapter ......................................................................319
Chapter 12 Safely Working with High Voltage .......................... 321
Lesson: Controlling High Voltage ...............................................322
PowerSwitch Tail ....................................................................322
EMSL Simple Relay Shield ......................................................323
Beefcake Relay Control Board ................................................324
Mini Project: Making a Fan Controller .......................................327
Instructions............................................................................328
Fan Controller Code ...............................................................329
Project: Making a Lava Lamp Buddy .........................................330
Decoding Infrared ..................................................................331
Instructions............................................................................332
Lava Lamp Buddy Code ..........................................................335
The Next Chapter ......................................................................338
Chapter 13 Controlling Motors ............................................... 339
How to Control Motors .............................................................340
Adafruit Motor Shield ............................................................340
Shmalz Haus EasyDriver .........................................................341
Bricktronics MegaShield .........................................................341
Powering Your Motor Using a TIP-120 .......................................342
Alt.Project: Stepper Turner ........................................................344
Instructions............................................................................345
Stepper Turner Code ..............................................................346
Project: BubbleBot ....................................................................347
Instructions............................................................................349
BubbleBot Code ....................................................................356
Glossary 359
9780789748836 TOC 11/1/2013