Arduino Playground Geeky Projects for the Experienced Maker 1st Edition Andrews all chapter instant download
Arduino Playground Geeky Projects for the Experienced Maker 1st Edition Andrews all chapter instant download
https://ebookultra.com/download/python-playground-geeky-projects-for-
the-curious-programmer-1st-edition-mahesh-venkitachalam/
https://ebookultra.com/download/the-geeky-chef-cookbook-real-life-
recipes-for-fantasy-foods-geeky-chef-4-cassandra-reeder/
https://ebookultra.com/download/practical-arduino-cool-projects-for-
open-source-hardware-technology-in-action-1st-edition-edition-
jonathan-oxer/
https://ebookultra.com/download/the-arduino-inventor-s-guide-learn-
electronics-by-making-10-awesome-projects-1st-edition-huang/
https://ebookultra.com/download/arduino-project-handbook-25-practical-
projects-to-get-you-started-1st-edition-mark-geddes/
https://ebookultra.com/download/arduino-for-dummies-1st-edition-john-
nussey/
https://ebookultra.com/download/programming-grails-best-practices-for-
experienced-grails-developers-1st-edition-burt-beckwith/
ISBN-10: 1-59327-744-X
ISBN-13: 978-1-59327-744-4
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press,
Inc. Other product and company names mentioned herein may be the trademarks of their
respective owners. Rather than use a trademark symbol with every occurrence of a trade-
marked name, we are using the names only in an editorial fashion and to the benefit of the
trademark owner, with no intention of infringement of the trademark.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by
any means, electronic or mechanical, including photocopying, recording, or by any informa-
tion storage or retrieval system, without the prior written permission of the copyright owner
and the publisher.
The information in this book is distributed on an “As Is” basis, without warranty. While every
precaution has been taken in the preparation of this work, neither the author nor No Starch
Press, Inc. shall have any liability to any person or entity with respect to any loss or damage
caused or alleged to be caused directly or indirectly by the information contained in it.
Brief Contents
Chapter 1: The Reaction-Time Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Appendix
Conte nt s in De ta il
1
The Reaction-Time Machine 1
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Reaction vs. Reflex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
How Does the Game Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Measuring Time with the Arduino Nano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Expected Speed Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
The Arduino Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Customized Reaction Commentary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
What Happens in the Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Preparing a Sturdy Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Mounting the Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Ideas for Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2
An Automated Agitator for PCB Etching 17
Special Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
How Automatic Motor Reversal Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Determining the Reversal Threshold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Using an H-Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
The Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
The Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Shield Design Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
The Limit Wires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
The Crank Bushing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
The Etching Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3
The Regulated Power Supply 45
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Required Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
A Flexible Voltage Regulator Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
How the Circuit Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Preparing the Arduino Pro Mini and LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Building the Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
The Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
The Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Preparing the Enclosure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Mounting the Circuit Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4
A Watch Winder 65
Why a Watch Winder? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Required Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Acrylic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Other Hardware and Circuit Components . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Basic Watch Winder Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Using an Arduino to Control Winder Revolutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Using a Hall Effect Sensor to Monitor Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
The Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
The Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Overview of the Motor Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Preparing the Motor Plate and Bearing Box Acrylic . . . . . . . . . . . . . . . . . . . . 87
Bonding the Acrylic for the Bearing Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
The Stand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Preparing the Motor and the Driveshaft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Making the Watch Basket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Adding the LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Leaving the Components on Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Keeping the Watches in the Basket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Design Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Total Rotation Adjustment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
How Many LEDs to Use and Where to Put Them . . . . . . . . . . . . . . . . . . . . . 101
Motor Voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
How Many Rotations Does the Watch Winder Make? . . . . . . . . . . . . . . . . . 102
Closing Thoughts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
5
The Garage Sentry Parking Assistant 105
Required Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Optional Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Basics of Calculating Distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
How the Garage Sentry Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
iv Chapter
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
The Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Inside the setup() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Inside the loop() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Determining Distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Triggering the Alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Drilling Holes for the Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Mounting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Soldering the Transistors and Current-Limiting Resistors . . . . . . . . . . . . . . . . . 123
Wiring the Pieces Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
The Deluxe Garage Sentry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
The Deluxe Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
A Bigger Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
The Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
The Sketch for the Deluxe Garage Sentry . . . . . . . . . . . . . . . . . . . . . . . . . . 128
6
The Battery Saver 133
Boats, Tractors, and Other Vehicles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Special Tool Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
The Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
How the Battery Saver Prevents Draining . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Arduino to the Rescue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
The Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
The Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
The Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
The PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Preparing the Shield and Pro Mini Controller . . . . . . . . . . . . . . . . . . . . . . . . 148
Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Preparing the Enclosure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
The Contact Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Preparing the Copper Contact Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Mounting Supplies for the Solenoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Preparing the Release Rod, Springs, and E-Clip . . . . . . . . . . . . . . . . . . . . . . 153
Making the Release Lever and Pylon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Assembling All the Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Installing the Battery Saver into a Vehicle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Operating the Battery Saver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Normal Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Setting the Threshold Voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Protection from the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Applying Cool Amp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Contents in Detail v
Arduino Playground (Early Access), © 2016 by Warren Andrews
1
T h e R e a c t i o n -T i m e M a c h i n e
stop button
Parts List
This project has one of the smallest parts counts of all the projects in this
book, but don’t let that attenuate its value for you. My family and friends
have enjoyed playing the game repeatedly, and it’s portable, so you can take
it with you to get-togethers and other events.
Here’s what you’ll need:
2 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
Downloads
Before you start this project, check the following resource files for this book
at https://www.nostarch.com/arduinoplayground/:
NOTE Sports Illustrated has done interesting work in this area, with eye-opening articles
on baseball players and other athletes who have what appear to be exceptional reac-
tion times.
Over the years, there have been many devices to measure reaction time. One
of the simplest I remember from years ago required you to keep your fingers
on either side of a ruler held by another person in mid-air. When the ruler was
dropped, you would see how far it traveled before you could grasp it. The dis-
tance was translated to time using the algebraic equation
1 2
S= AT ,
2
where S is the distance traveled, A is the acceleration due to gravity, and T
is the reaction time. After you build this project, try both the ruler test and the
Reaction-Time Machine to see how close your times are between devices.
4 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
together. You can always edit the commentary and reload the sketch to show
comments specific to a set of users, like friends or relatives.
The Schematic
While the display could have been wired directly, using the I2C inter
connect made it a lot simpler and reduced the interface to only four wires:
positive, ground, data, and clock (see Figure 1-2).
The only components needed are the Nano, three switches (one toggle
switch for power and two momentary push-button switches for activate and
reset), an LED, the display, and three resistors. Despite the relatively sparse
parts count, the project performs elegantly.
The Breadboard
As is the case for most of my Arduino projects, the first step is to prepare a
breadboard to prove the concept and test the sketch. Here’s how to wire up
the breadboard:
6 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
16. Connect a 10-kilohm resistor from pin D7 on the Nano to the red
strip (5V).
17. Connect a 10-kilohm resistor from pin D2 on the Nano to the red
strip (5V).
18. Connect the anode side of the LED (the longer leg) to the red strip
on the breadboard (5V) and the cathode side to an empty row on the
breadboard.
19. Connect a 470-ohm resistor from the cathode side of the LED to pin D4
on the Nano.
Figure 1-3: The breadboard setup for the Reaction-Time Machine. Because there is no
on/off switch, you have to disconnect the battery to shut it off.
/*
Includes score function, random number generation, false start
"jump the gun" indicator, and multiple comments spaced 10 ms apart
int start_time = 0;
int stop_time = 0;
int reacttime = 0;
int x;
int R;
int randnumber1;
int z;
void setup() {
Serial.begin (9600);
pinMode(2, INPUT);
pinMode(4, OUTPUT);
pinMode(7, INPUT);
lcd.init();
lcd.backlight();
}
//Begin function "score"
void score() {
lcd.clear();
lcd.print("Reaction Time ");
lcd.print(reacttime);
lcd.print(" ms");
lcd.setCursor (0, 1);
8 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
lcd.setCursor(0, 3);
lcd.print("a lot better");
}
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print(" ");
2
The #include lines initiate the libraries: the I C library, Wire.h, establishes
2
the rules for I C communications, and the LiquidCrystal library allows the
Arduino to control LCDs. Then, we define the seven variables used to calcu-
late reaction time. Next, setup () sets up the serial communication—in case
you want to adjust the code and view it on the serial monitor—and defines
various pins as inputs and outputs. Inputs are required for the reset and
stop buttons, and an output pin is defined for the LED that tells the player
when to press the stop button.
10 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
NOTE You can find reaction-time measurement tools on the Web if you want to see how
your game’s measurements compare. However, their accuracy is suspect because of
the latency in the PC itself.
There are a few points to note about the setup of the LCD display. The sketch
uses a LiquidCrystal library, LiquidCrystal_I2C.h. If this library is not included
in your Arduino IDE, you can easily download it using the instructions pro-
vided in the reference section on the Arduino website (http://www.arduino
.cc/reference/).
2 2
In addition, each I C device comes with its own I C address. This allows
2
several I C devices to be used on a single serial line. Usually the device docu-
2
mentation provides the address—in the case of the I C LCD I used, the address
was 0x3F. Thus, when the sketch initiates the LCD, the code looks like this:
NOTE A wider range of random numbers might make this game even more interesting for
players. You can easily experiment by changing the random number count, the delay,
or both.
Construction
Building the Reaction-Time Machine can be as simple or as complex as
you want. Initially, I placed all the components in the vinyl package that
a flexible wrist brace came in. I cut a hole for the display connectors with
an X-ACTO knife and punched the holes for the switches and LED with a
paper punch, followed by a tapered reamer. The result was somewhat crude,
as shown in Figure 1-4.
12 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
Figure 1-4: This was the Reaction-Time Machine’s original, primitive package, which
worked but turned out to be too flimsy. The vinyl was only 0.018 inches thick.
0.75"
0.75"
1/4" 1/4"
NOTE The 3.5 mm jack is wired in parallel to the execute switch. If you want to use an
external stand-alone switch, it can simply plug in to the jack. I abandoned the effort,
however, as most participants preferred to hold the box in their hands.
Figure 1-6: This is the rear of the unit mounted in the ABS plastic enclosure. Notice that
the corners of the display (lower left and right) have been clipped off to fit around the
top mounting pylons. The 3.5 mm jack is not wired, as I decided not to use it in this
implementation.
14 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
Once all the components are in place, all that remains is to solder the
components together, inserting the resistors where required. Take par-
ticular note of the I2C adapter, which is the black paddleboard just below
the switches and LED. While I could have bent the connectors and used a
header to wire that up, the case may not have closed, depending on how
carefully I crimped the connectors. Instead, I elected to solder the wires
directly. It was only four wires, and it worked without much trouble. Finally,
I printed out and attached labels from a Brother label maker. Figure 1-7
shows the completed unit.
Figure 1-7: The completed Reaction-Time Machine mounted in the Hammond 1591 STCL
clear plastic enclosure
16 Chapter 1
Arduino Playground (Early Access), © 2016 by Warren Andrews
2
A n Au t o m a t e d A g i t a t o r
f o r P C B E t c h i n g
10 or 15 minutes to well over half an hour! Standing there stirring the pot is
pretty boring, but you can create a device that dunks the board in and out
of the solution for you (see Figure 2-1).
Hub to hold crank
Set screw
Screw holding crank Motor
Motor
Limit
Limit Limit
Crank Crank
Rotation
Line Line
Etchant Etchant
Figure 2-1: Illustration of the motor, crank, and etching vessels set up to dip a circuit board
in and out of the etchant. While there are many ways to agitate a circuit board, dipping it
into and out of the etching solution works well, especially for small boards.
18 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
Special Tools
There are only a couple of special tools you will need. One is a 6-32 tap you
can buy at Ace Hardware for a little over $1. But if you want a complete tap
and die set for future projects—which is probably a good idea, as they’re
also just handy to have around the house—you can pick up a set at Harbor
Freight (http://www.harborfreight.com/) for under $10 (item #69679). Other
vendors offer similar items.
A handful of drill bits are also required. You can purchase drill bits
individually, or you might think about getting an entire set. Once again,
our friends at Harbor Freight have drill sets starting at under $4. It’s always
useful to have some drill bits around, so if you can afford it, a numbered
drill set— #1 through #60—would be a good investment.
Of course, a drill is also useful—and necessary. See “Tools” on page XX.
Parts List
• One Arduino Nano (Available from Newegg, Mouser Electronics,
and other retailers. You could also purchase a clone on eBay for just
under $6.)
• One SN754410 quad H-bridge IC, with socket if desired (Available from
eBay, Newark Electronics, Mouser Electronics, Digi-Key Electronics,
and other suppliers. Note that if you use the socket, you lose whatever
value the PCB offers as a heat sink.)
• One printed circuit board (PCB) or perf board
• One current-limiting resistor (You should have a selection available
for experimentation, from 1 ohm to 10 ohm. You can buy resistors
from many suppliers, including Jameco, MCM, Mouser, Digi-Key, and
Newark, for under $0.05. A 1/8 W resistor will work for smaller motors,
but get a 1/4 or 1/2 W resistor for larger loads.)
• Two 330-ohm, 1/8 W resistors (Available through previously listed
suppliers)
• Two LEDs, one red, one green (Available on eBay and elsewhere for
under $0.10 each. Consider buying an assortment, as we’ll use them in
upcoming projects.)
Downloads
Before you start this project, check the following resource files for this book
at https://www.nostarch.com/arduinoplayground/:
• Sketch: Reverse_IV_3.ino
• Shield (PCB): Reverse.pcb
• Template: Motormount.pdf
20 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
The motor circuit you’ll connect to the Arduino uses a resistor between
the power supply and the motor (see Figure 2-2). When the motor slows or
stalls, the current increases, creating a voltage drop across the resistor.
Voltage drop
R
measured here
Motor
The voltage drop across resistor R is the real-world input to the micro-
controller. In this project, that voltage drop is fed to the Arduino Nano’s two
analog input pins that straddle the dropping resistor. The microcontroller
digests this input and creates an output designated by your program.
NOTE You could implement the circuit with only a single analog input, but that would
curtail some of the flexibility of the circuit—particularly if you use motors that run
at different voltages.
The Schematic
The agitator circuit feeds the voltage that appears across resistor R1 into
two of the Arduino’s analog input pins, A0 and A1, setting up the real-world
input (see Figure 2-3).
All grounds in this circuit are connected together, and the voltage
across pins A0 and A1 is the voltage your program will use to decide
when to reverse the motor’s direction. Note that this voltage is not refer-
enced to either the positive or negative rail, but it must be between 0 and
5V to prevent damage to the microcontroller. If you get stuck on wiring the
H-Bridge, see “Using an H-Bridge” on page 25.
Figure 2-3: The completed schematic for this project shows the 5.6-ohm voltage-drop resistor (R1), the two
LEDs (D), the 330-ohm current-limiting resistors (R2 and R3), and the quad H-bridge (SN754410), of which
half is used.
22 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
40 A
× 5.6Ω = 0.224 V
1000
Now, go back to the ADC. It has 1,024 units to represent 5V, so each
unit represents 0.0049V. A little arithmetic reveals that the 0.224V dropped
represents about 46 units out of the 1,024:
0.224 V
= 45.85 units
0.0049 V per unit
There are some estimates you have to take on faith—at least until you
confirm with a test. This is one. As a motor is slowed or stalled, the current
drain increases. Depending on the motor, the increase in current is typi-
cally somewhere between two and four times the normal current drain, but
possibly more.
NOTE With no load (or minimal load), current drain on the motor is minimal. With a
usual running load, current can be four to five times the no-load current. With a
heavy load, current can be as much as 10 times that, depending on the motor design.
Build the circuit as shown in Figure 2-6, and then connect the red
lead of the multimeter to the power supply. Connect the black lead of the
multimeter to the motor lead to complete the circuit. If the reading is nega-
tive, reverse the red and black leads of the multimeter. Depending on your
power supply voltage and the motor’s voltage requirement, you may also
need to connect the motor to power through a voltage regulator circuit, as
described in “The Voltage Regulator” on page 34.
Power supply/battery
Negative terminal Positive terminal
Figure 2-6: Connection diagram for measuring the current drain of the motor
To check the current drain, hold the shaft of the motor to slow it, and
watch the readout on the multimeter. You can get an accurate indication of
the number of ADC steps by plugging your readout in to Ohm’s law, calcu-
lating the voltage, and converting into steps, as I did.
24 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
NOTE In the sketch, I use a value of 100 as the threshold for reversing. You could also calcu-
late the absolute value of the voltage drop by multiplying 100 by 0.0049V:
100 steps 0.0049V per step = 0.49V
Using an H-Bridge
You’ll likely encounter an H-bridge driver in future projects because it’s a
very versatile part and can serve numerous functions. There is quite a selec-
tion of H-bridge chips available, but I’ve been using the Texas Instruments
SN754410 quad H-bridge. It’s popular because it operates over a wide volt-
age range and is extremely flexible—and inexpensive. The logic operates at
a 5V level, while the drive can be as much as 36V with a continuous output of
1A (and a peak output of 2A), making it capable of driving a wide variety of
hobby motors, solenoids, and even relays. It comes in a standard 16-pin dual
inline package (DIP). The DIP package was a longtime standard but is slowly
being replaced by newer types (see “Dealing with Small ICs” on page XX).
It’s the conventional centipede-looking circuit.
Figure 2-7 shows the pinout for the SN754410 H-bridge, and Table 2-1
shows its function table. You’ll find more information in Texas Instruments’
data sheet at http://www.ti.com/lit/ds/slrs007b/slrs007b.pdf.
1,2EN 1 16 VCC1
1A 2 15 4A
1Y 3 14 4Y
2Y 6 11 3Y
2A 7 10 3A
VCC2 8 9 3,4EN
Figure 2-7: The pinout for the SN754410 quad H-bridge chip
used in this project. Note that pin 1 is in the top-left corner of
the chip when viewed from the top with the notch pointing up.
According to the data sheet, in this function table, H stands for high
level, L stands for low level, X means the level is irrelevant to the circuit
behavior, and Z indicates high impedance, which turns the motor off.
The H-bridge is an elegant motor-control solution for several reasons.
It allows you to reverse the polarity from a single supply, and it provides for
different logic and control voltages. In addition, if both inputs of the dual
H-bridge are either high or low, there will be no output. The sketch takes
advantage of that in a function written to stop the motor. Other projects in
this volume also use this capability.
The Breadboard
For most Arduino projects, I suggest building the circuit on a breadboard
first to make sure you’re going in the right direction and to prove your ini-
tial hypothesis. Use a standard breadboard and the plug-in wires that are
sold as accessories for the breadboard (see Figure 2-8).
26 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
Before you begin building the circuit on the breadboard, look over
your Arduino. Many Arduino boards come complete with the male headers
already soldered in place. However, that’s not always the case; some Asian
suppliers include the headers loose with the processor board. If your board
lacks headers, see “Preparing Arduino and LCD Boards” on page XX for
complete instructions on attaching them.
Most breadboards include a red and blue strip on the entire length of
each side of the board; the holes next to these strips are used for power (+)
and ground (-), respectively. Before you hook up the circuit, use a wire to
connect the red column on the right to the red column on the left. Connect
the blue columns to each other, too.
Warning Do not connect the red column to the blue column! This will cause a short circuit and
will burn out the electronics.
Figure 2-9 shows my breadboard for this project, and the schematic
from Figure 2-3 lays out the connections.
Figure 2-9: This is the breadboard I used as a proof-of-concept to make sure every-
thing worked as anticipated.
Warning Don’t plug the Arduino in to the computer while it is actually receiving power from
the voltage regulator. This could burn out the Arduino.
1. Insert the Nano board into the breadboard, leaving a couple of rows of
holes at one end.
2. Place a wire from the pin labeled 5V on the Nano (pin 27) to the posi-
tive (red) strip on the breadboard.
3. Place a wire from GND on the Nano (pin 29) to the negative (blue)
strip on the breadboard.
4. Find three consecutive holes on the board where they will not connect
to anything and insert the three leads of the LM7805 into them.
5. The input lead of the LM7805 will go to the 9V power supply, the
ground of the LM7805 will go to the blue negative rail, and the output
of the chip will go to the red stripe. (See Figure 2-11 for the LM7805
pinout.)
6. Insert the H-bridge into the breadboard with the notch facing the
Nano, and leave a couple of rows between the H-bridge and the Nano.
7. Use a wire to connect pin 1 and pin 16 of the H-bridge together (see
Figure 2-7). Then, use another wire to connect pin 1 to the positive
connection on the breadboard. This connection from pins 1 and 16
provides the voltage to run the logic on the H-bridge and also to enable
the section of the H-bridge used.
8. Use a wire to connect pins 4 and 5 of the H-bridge, and then connect
them to the negative terminal on the breadboard. Running a wire from
either pin 4 or pin 5 to ground will do the trick.
9. Similarly, connect pins 12 and 13 of the H-bridge together, and connect
them to ground.
10. Use a wire to connect one side of the motor (it doesn’t matter which) to
pin 3 of the H-bridge, and connect pin 6 of the H-bridge to the other
side of the motor.
11. Connect digital pin D12 of the Nano to pin 2 of the H-bridge.
12. Connect digital pin D13 of the Nano to pin 7 of the H-bridge.
13. Connect one side of the 5.6-ohm resistor (R1) to pin 8 of the H-bridge.
14. Connect the other side of resistor R1 to the breadboard’s positive strip.
15. Insert a wire from pin 8 of the H-bridge to analog pin A0 of the Nano.
16. Insert a wire from the positive (red) connector to analog pin A1 of
the Nano.
17. Insert the positive side (long lead) of one LED to D12 of the Nano.
18. Insert the negative side of the LED into an empty row on the
breadboard.
19. From that row with the negative side of the LED, connect a 300-ohm
resistor (R2) to ground (blue strip).
20. Insert the positive side (long lead) of the second LED to D13 of
the Nano.
21. Insert the negative side of the second LED into an empty row on the
breadboard.
22. From that row with the negative side of the second LED, connect a 330-
ohm resistor (R3) to ground.
28 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
The VCC2 supply drives the output to the motor. It goes from the posi-
tive side of the supply—the output pin of the regulator in the schematic—
through resistor R1 to pin 8 of the H-bridge. VCC2 becomes the low-voltage
side of resistor R1; it will have a lower voltage as the load on the motor
increases because the other end of the resistor is attached to the positive of
the power supply. The VCC2 supply voltage can be anywhere from the 5V
that the logic uses to the 36V limit of the H-bridge. For this project, I simply
tied the voltage-drop resistor directly to the 5V supply, which worked well
with a 6V motor.
The Nano’s D12 and D13 output pins drive the A inputs of the
H-bridge, while A0 and A1 inputs straddle the voltage-drop resistor, R1.
It’s this voltage-drop value that tells the Arduino to change the outputs
to instruct the H-bridge to reverse the motor. When output D13 is high
and D12 is low, output pin 2Y on the H-bridge becomes positive while 1Y
remains negative. When D12 is high and D13 is low, the reverse happens,
and 1Y becomes positive while 2Y stays negative. When both pins have high
or low output, they are at the same potential (or voltage), and the motor is
not driven. (Refer to the function table in the H-bridge chip’s data sheet, or
see Table 2-1.)
The Sketch
The following sketch is written so that when the motor reaches its limits
in one direction, both outputs go low, and when it reaches its limits in the
other direction, both outputs go high. When both outputs are either high
or low, there is no potential across the motor and it is stopped for a speci-
fied delay time. After the delay is satisfied, the motor starts in the other
direction. Because LEDs are wired to pins D12 and D13, you’ll also get a
visual indication. Both LEDs are illuminated when the motor pauses in
one direction, and both LEDs are off whe the motor pauses in the other
direction.
int reading;
int state;
int previous = LOW;
int count = 0;
int numberstops = 250;
int time = 0; //The last time the motor reversed
//Amount of time to wait to get rid of the jitters when the motor reverses
int debounce = 400;
//These were added to view what was happening on the serial monitor
Serial.print("count = ");
Serial.println(count);
Serial.print("analogdifference = ");
Serial.println(analogdifference);
Serial.println();
Serial.print("numberstops = ");
Serial.println(numberstops);
30 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
}
//Increments the counter each time the motor reverses
z count++;
time = millis();
}
//Writes the state to the output pins that drive the H-Bridge
digitalWrite(ledPin1, state);
digitalWrite(ledPin2, !state);
previous = reading;
This sketch sets up human-understandable aliases for the pins the proj-
ect uses and adds convenient constants and variables for referencing analog
inputs and other key values. After the sketch defines and initializes the input
and output pins at , it starts the main loop at .
Inside the main loop, the sketch finds the voltage drop across the resis-
tor in terms of analog steps . At , the sketch determines whether the
reading was high or low. Threshold values from 100 to 120 work reliably for
the 6V, 20 RPM motor I used, but you may need to experiment to find the
right value for your motor. See “Determining the Reversal Threshold” on
page 22 for more on how to estimate the threshold value. The reading
at dictates whether to reverse the motor.
I’ve tried this reversing circuit with several similar motors, and I’ve only ever
needed to make a slight adjustment to the threshold value in the sketch. But
for a motor with extremely high or low current drain, you may need to antici-
pate a much different value for analogdifference and/or use a different drop-
ping resistor, which was R1 in the schematic. You might need to reduce the
value of the dropping resistor to something like 2.2 ohm, which then requires
a reduction in the value you compare analogdifference to.
For most small motors, the lower the value of the dropping resistor—which
is usually between 1 and 10 ohm—the better, as the analog difference tends
to be more stable. For other motors, experiment to find the resistor value that
works best.
When the sketch checks reading to see whether the motor needs revers-
ing, it also uses the debounce value to assure that a high reading wasn’t caused
by electrical noise created by the motor’s commutator or brushes during a
legitimate reversal. I set debounce to 400, but you may have to adjust that for
different motors. For larger motors specifically, this may need to be set a
little higher.
This sketch also includes a few functions that aren’t strictly necessary to
reversing the motor but are helpful when using the motor as a PCB agitator.
These aspects of the project may appeal to you in other applications, too, so
let’s look at them in more detail.
One of the things that I added was a counter to track the number of
times that the motor reversed. In the sketch, the count increment appears
at z as count++. In the project, when a certain value of count is reached,
the motor stops (if count = numberstops). If you wanted to set off an alarm,
such as an audible noisemaker, to tell you it’s finished, that can easily be
accomplished by adding a line to write to one of the digital outputs. I set
a maximum count value in the sketch, using numberstops = 250, so the motor
will reverse 250 times and then stop. That provides a little more than 15
minutes of etching time with the motor I’ve selected running at 5V, which
should be enough to etch most circuit boards.
The stop function is just a do-nothing loop: when the maximum count
is reached, the sketch enters the while loop at the beginning, stopping the
agitation. This basically stalls the processor, and you have to hit the power
switch to restart, or reset, the agitator. The placement of this loop near the
beginning of the software is just a reminder that it’s there.
If setting a fixed stop maximum in a sketch doesn’t leave you satisfied, try
connecting a potentiometer between power and ground with the adjust pin,
which is usually the center pin on the potentiometer, to the A2 input pin of the
Arduino. Then, set numberstops equal to the value of A2, which should range
from 0 to 1,023, depending on the position of the potentiometer wiper.
Here’s how the sketch would differ. First, change
numberstops=250
to
numberstops = setNumber;
int setNumber;
int analogPin2 = A2;
int analogValue2;
setNumber = analogRead (analogPin2);
Because the timing is relative, you could use a 270-degree rotation linear
potentiometer and make some rough markings on the enclosure to indicate the
number of counts.
32 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
The thinking behind the count, optional alarm, and stop capabilities
is that a reminder to check on your board is helpful. If the board has com-
pleted etching, continued agitation would speed undercutting of the traces,
which is not a good thing because it weakens (and can break!) small copper
traces. On the other hand, if it fails to etch in a reasonable time, you might
need to refresh the etchant.
The Shield
For this project, I recommend making a small PCB shield, which is basically
a host board designed to plug into the Arduino Nano. With a shield, your
motor reversal project can remain compact, and you can design and build it
with a minimum of effort.
PCB Layout
You could just solder the parts for your project directly to a piece of perfo-
rated project board, but I believe creating and populating the shield takes
less time than putting the parts on a perforated board and wiring them by
hand. You’ll also gain invaluable experience by preparing, etching, drill-
ing, and assembling your own PCB. And in the end, some projects are com-
plex enough that wiring by hand just won’t be an attractive option. (See
Figure 5-12 on page 69 for an example.)
To make my printed circuit layouts, I use a free software program
called ExpressPCB. If you’ve never laid out a PCB before, check out
“Making Your Own PCBs” on page XX to learn how to use ExpressPCB.
Figure 2-10 shows my layout of the PCB.
If you don’t want to lay out your own PCB but still want to make
the board, download the Reverse.pcb file from https://www.nostarch.com/
arduinoplayground and follow the directions in “Making Your Own PCBs”
on page X. When you’ve made your PCB, just solder all the components
to it in the right places, and you’ll be done with the shield.
Analog Inputs
Be certain to connect the A1 and A0 inputs to the correct sides of resis-
tor R1, according to the schematic in Figure 2-3. A1 should attach to the
power supply side and A0 to the H-bridge side. In the sketch, to compare
the analog values, we take the difference as analogdifference = analogValue1 –
analogValue0, with analogValue1 as the input at the high end of the resistor. In
this case, analogValue0 is A0, and analogValue1 is A1.
Output
Common
Input
You could feed a 7.5V DC or 9V DC wall supply directly to the VIN pin
of the Nano and use the onboard regulator, which worked with my motor.
But if you use a larger motor—or higher-current LEDs—it might tax the
onboard regulator and could conceivably burn it out.
The higher the voltage of the power supply, the more work the regula-
tor has to do to bring it down to 5V. Overtaxing the regulator could cause
34 Chapter 2
Arduino Playground (Early Access), © 2016 by Warren Andrews
it to heat up and fail. For example, feeding the regulator 12V is probably
at the high end for 5V regulation. A 9V input is better, and a 7.5V input
is better yet. If the regulator chip gets warm, add a heat sink to the tab. A
small piece of aluminum is often sufficient, but a regular heat sink can be
used (see “The Mini Voltage Regulator” on page X). And while it’s good to
have the supply voltage as close to the output voltage as possible, remember
that the regulator needs at least 1V above the regulated output to work, so
it must be fed with at least 6V, which is a 5V-regulated output plus 1V. Input
voltages above 12V are feasible, too, but just be sure not to exceed the limits
of the device.
If you use a higher-voltage motor for this project, it will turn faster, have more
torque, and so on. But you can’t simply connect the higher voltage to the high
end of the dropping resistor connected to pin 8 of the H-bridge. That would
cause the voltage between both A0 and A1 and ground to exceed 5V, which
is hazardous to the health of the ATmega328 microcontroller on the Arduino.
(This is the only time that the voltage referenced to ground is important.) Thus,
a modification is required. Look at R1 in the schematic in Figure 2-12. The sup-
ply first goes to resistor R2; R2 joins with resistor R3, which goes to ground.
To avoid damage to the Nano processor, you will want to keep the volt-
age that appears at that joining point under 5V, referenced to ground. The
easiest way to do this is to use a voltage divider. Two resistor pairs divide the
higher voltage: the first pair is R2 and R3; the second is R4 and R5. The value
of these resistors should be such that the output at the joining of each pair—R1
and R2, and R4 and R5—is somewhat less than 5V for whatever value of input
voltage you use.
Use this formula:
R2
Vout = Vin ×
R1 + R 2
and the schematic in Figure 2-13 to determine the values of the resistors to use
in a voltage-divider circuit.
For example, if you start with 9V and arbitrarily Vin
select a 10-kilohm resistor in series, you would have to
shunt it with a 12.5-kilohm resistor to ground, accord-
ing to the calculator. The closest resistor I had was R1
12 kilohm, and it worked fine. If you can’t find a stan-
dard resistor to fit your needs, you can also combine Vout
two standard values in parallel to achieve the value you R2
want with this formula:
R1 R2 Ground
Rtotal =
R1 + R2
Figure 2-13: A basic
If you don’t want to do the algebra yourself, you voltage divider. To
find the resistors you
could use one of the convenient online voltage-divider should use, plug the
calculators such as http://www.sengpielaudio.com/ values from your
calculator-paralresist.htm or http://www.raltron.com/ own divider into the
formula as if your
cust/tools/voltage_divider.asp. SparkFun also has an divider were this
excellent tutorial on voltage dividing, with a calcula- circuit.
tor of its own: http://learn.sparkfun.com/tutorials/
voltage-dividers/.
Directional LEDs
Of course, what Arduino project would be complete without blinking
LEDs? As you’ll see in the schematic and on the shield PCB, I included
two LEDs: a red one for clockwise rotation and a green one for counter
clockwise rotation. But which direction belongs to which LED is your
choice: simply reverse the motor leads to change the LED status.
36 Chapter 2
Another Random Scribd Document
with Unrelated Content
The 5th we marched nine miles through deep mud and rain to the
battlefield in front of Williamsburg, the last four and a half on the
double quick and a run. The men, exhausted, in profuse
perspiration, and wet to the skin, were obliged to lie on their arms
during the night without either blankets or fires. From that hour the
sickness of the regiment increased frightfully, six or eight new cases
occurring daily. We left twenty-seven men in hospital at
Williamsburg, sent six to transports at West Point when opposite that
place, sent sixty away at Cumberland Landing, left forty-eight at
Baltimore Store, and had sixty-four on the sick list at Bottom's Bridge
on the 31st of May.
At the battle of Fair Oaks, on the last day of May, we lost of men and
officers eleven killed and forty-nine wounded. Of the last, twenty-
three were wounds of the upper extremities, two requiring
amputation of the arm, and one exsection of the elbow joints;
twelve of the lower extremities, four of thigh, seven of leg, and one
of knee joint, eight of trunk (three serious); six of head (one
serious), and two of both upper and lower extremities.
While at Fair Oaks from the 1st to the 29th of June, the regiment
suffered greatly from fever and dysentery, the first of miastamic
origin, which, together with the effect of constant apprehension,
rendered the nervous system highly impressible. Hence the marked
effect of the malaria upon the nervous centers, especially the spine,
as evidenced by the almost constantly present—to a greater or less
degree—numbing of the extremities with partial paralysis of the
lower, usually severe pain in the hips and lumbar region, with great
depression of spirits, etc.
The diarrhoea, as well as all diseases resulting from bad digestion or
affections of the digestive organs, were caused mainly, if not
entirely, by improper habits of cooking and eating. Each soldier
cooked for himself, having no other implements than a small tin pail
made from fruit can, a tin cup and a borrowed frying pan. Every
leisure moment was devoted to cooking and eating; meat of every
description was fried instead of being boiled. All regularity in eating
was lost, except that uncertain kind, produced by relief from the
routine of duty. Nor can any remedy be suggested short of the entire
removal of the cooking business from the hands of the soldier, and
placing it in charge of a competent corps organized for that special
purpose. Soldiers cannot march and fight each with a complete stock
of cooking furniture on his back.
In an active campaign like that on the Peninsula, officers suffer from
bad cooking equally with the men. Servants are an uncertain kind of
dependencies and often obliged to cook for himself, the officer is of
course as unskilled as the soldier. A regimental mess for the officers
of this regiment under charge of a competent cook, established a
few weeks ago, has already proved decidedly advantageous. A
similar arrangement for the men, for instance by companies, would
be found to be as great an improvement.
For five days before commencing the retreat from before Richmond
to Harrison's Landing our men were almost constantly on duty. On
the 29th of June they skirmished all day, then marched half of the
night. The next day (30th) they fought at Charles City Cross Roads,
losing seven killed and fifty-six wounded, most of whom fell into the
hands of the enemy. They watched until two o'clock a. m., July 1st,
then marched to Malvern Hill, fought there, losing two killed and
eight wounded; remained on picket until 9 a. m. next morning, then
marched twelve miles through deep mud and hard rain to Harrison's
Landing, camped at night in the mud, then moved three miles and
camped permanently for outpost duty.
All were exhausted and disheartened, scarcely a well man in the
regiment, two hundred and thirty on the sick list for the first few
days. Scurvy made its appearance to a small extent, yet sufficient to
complicate and multiply other ailments. However, a few weeks' rest,
abundance of fresh vegetables, lemons and ice, and we were ready
to commence the retreat from the Peninsula with two hundred and
fifty men for duty, having lost four by death at Harrison's Landing—
two by typhoid fever, one from entraperitonitis and one from phthisis
pulmonalis.
On reaching Alexandria we immediately moved to the
Rappahannock, had no sickness of moment except two cases of
sunstroke, being actively engaged, yet not overworked.
We had three wounded at Bull Run, one in the hand, one in the hip,
and one in the breast and face. These last two have since died.
The present health of the regiment is good and its moral condition
excellent.
The general conclusions we arrive at are:
First.—That constant seasonable activity is necessary to promote the
health of the regiment.
Second.—Men accustomed to exposure in the open air when
attacked by fever of any kind, recover with much more certainty and
much sooner in tents than in general hospitals in houses, probably
because less crowded and admitting more perfect ventilation, and
free access to light.
J. W. LYMAN,
Surgeon 57th Reg't., Pa. Vols.
APPENDIX C.
THE 57th PA. VETERAN VOLUNTEERS.
The 57th Regt., Pa. Vet. Vols., which was made up largely of Mercer
county men, dedicated, on Monday, July 2d, one of the finest
monuments on the Gettysburg field.
The exercises were opened with prayer by Rev. Dr. Sayres,
Department Chaplain of the G. A. R., after which Col. L. D. Bumpus,
President of the Monument Committee, introduced Capt. H. H.
Hinds, who made a few remarks on the movements of the 3d corps
and the work done by the 57th regiment. When Captain Hinds had
concluded, the audience sang the hymn "America," after which Capt.
D. W. Gore, Secretary of the Monument Association, introduced Col.
L. D. Bumpus in the following speech:
It would not be necessary to introduce the orator for this occasion to an
audience composed of the members of the old 57th regiment, but as there
are many strangers present it would perhaps be proper for me to say that he
is a man who was identified, with the 57th regiment during the entire history
of its eventful existence. He was with us in our various marches, in our
numerous encampments, and in our many hard-fought battles. He entered
the army as a mere boy and rose from the ranks to the command of the
regiment before reaching his majority. He was known throughout the army as
the boy captain. It is largely due to his tireless efforts that we are enabled to
dedicate this beautiful monument today. He was true to his country, true to
himself, and true to the men of his command. No braver officer ever drew a
sword in defence of the old flag and no man enjoyed to a greater degree the
respect and regard of his old comrades in arms than does Col. L. D. Bumpus,
whom I now introduce to you as the orator for this occasion.
Comrades, in all countries and in all ages the people have reared
monuments to the memory of their dead heroes; their deeds of valor
have been told in song and story, and the people have delighted to
do them honor. The great Commonwealth of Pennsylvania,
recognizing the services of her brave soldiers, during the sitting of
the last Legislature passed an act appropriating fifteen hundred
dollars to build a monument to each regiment that participated in
the battle of Gettysburg. In accordance with the provisions of that
act, Capt. D. W. Gore, Capt. H. H. Nelson, Lieut. George Miller,
Comrade Theodore Catlin and myself, were elected as a committee
by the surviving members of the regiment to select the location,
submit designs, and erect a monument.
We organized at Gettysburg by electing your speaker chairman, and
Captain Gore secretary. Not knowing the magnitude of the work
before us, July 2d was agreed upon as the day upon which our
monument should be dedicated. Scattered as the members of the
committee were, over two States and the District of Columbia, thus
rendering it difficult to convene them, it was thought best that the
chairman and secretary be authorized to act for the committee. The
labor and expense thus devolved upon us have been considerable.
We have been met with many and unlooked for obstacles; but one
by one they have been overcome, and the result of our work is
before you.
As chairman of your committee, in the name of the taxpayers of the
Commonwealth of Pennsylvania, I present you with this beautiful
monument, which will stand while generations pass away, as a
monument to the valor and patriotism of the 57th regiment, and to
the generosity of the citizens of this grand old State. Pennsylvania
honors herself in thus honoring the memory of those who fell in her
defence. We dedicate this memorial shaft, not to those who fell at
Gettysburg alone, but to the eight hundred who were swallowed up
by the tide of death on other fields; in prison pens, in hospitals, and
on the lonely picket line. We dedicate it to every member of that
grand old regiment, either living or dead. We dedicate it to our
children and our children's children forever.
And when the few of us who yet survive shall have passed on to
"join the innumerable caravan," may coming generations, as they
gather 'round this granite shaft and read the record chisled here,
learn lessons of patriotism and heroic devotion and here may they
gain inspiration and strength, which shall make them brave
defenders of their country's institutions and her flag, which we so
much love.
Comrades, I cannot refrain from saying a few parting words to you.
As I look over this audience, I am reminded that the boys of 1861
are now men on the down-hill side of life. The hand of time has
silvered the hair and plowed deep furrows in the cheeks of the
comrades I see gathered about me, and this will probably be the last
roll-call to which a considerable number of the old regiment will
respond. Soon these pleasant meetings, these delightful and
hallowed associations, with each and all of us must come to an end.
Let us live all the more closely together, then, in the brief road that
remains to us. Let us be truer to our common name and common
fame, so that we shall leave nothing behind us which will tarnish the
polished and war-worn escutcheons of the grand old 57th regiment.
Let us continue to be good citizens. Let us lead such lives that when
we hear the last tattoo and the lights are ordered out on earth, we
shall be awakened by the reveille at the tent of the Great
Commander and bidden to seats at Headquarters.
Transcriber's Notes:
Missing or obscured punctuation was corrected.
Typographical errors were silently corrected.
*** END OF THE PROJECT GUTENBERG EBOOK HISTORY OF THE
FIFTY-SEVENTH REGIMENT, PENNSYLVANIA VETERAN VOLUNTEER
INFANTRY ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com