Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

Arduino and Raspberry Pi Sensor

Projects for the Evil Genius 1st Edition


Chin
Visit to download the full and correct content document:
https://ebookmeta.com/product/arduino-and-raspberry-pi-sensor-projects-for-the-evil-
genius-1st-edition-chin/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Raspberry Pi Electronics Projects for the Evil Genius


1st Edition Norris

https://ebookmeta.com/product/raspberry-pi-electronics-projects-
for-the-evil-genius-1st-edition-norris/

Beginning Sensor Networks with XBee, Raspberry Pi, and


Arduino, Second Edition: Sensing the World with Python
and MicroPython Charles Bell

https://ebookmeta.com/product/beginning-sensor-networks-with-
xbee-raspberry-pi-and-arduino-second-edition-sensing-the-world-
with-python-and-micropython-charles-bell/

Raspberry Pi Projects for Kids 1st Edition Daniel Bates

https://ebookmeta.com/product/raspberry-pi-projects-for-kids-1st-
edition-daniel-bates/

Raspberry Pi Home Automation with Arduino 1st Edition


Andrew K Dennis

https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-1st-edition-andrew-k-dennis-2/
Raspberry Pi Home Automation with Arduino 1st Edition
Andrew K Dennis

https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-1st-edition-andrew-k-dennis/

Raspberry Pi Home Automation with Arduino Second


Edition Dennis Andrew K

https://ebookmeta.com/product/raspberry-pi-home-automation-with-
arduino-second-edition-dennis-andrew-k/

The Complete Manual Raspberry Pi Coding Projects 12th


Edition 2022 Bdm

https://ebookmeta.com/product/the-complete-manual-raspberry-pi-
coding-projects-12th-edition-2022-bdm/

Embedded Robotics Mobile Robots with Raspberry Pi and


Arduino 4th Edition Thomas Bräunl

https://ebookmeta.com/product/embedded-robotics-mobile-robots-
with-raspberry-pi-and-arduino-4th-edition-thomas-braunl/

A Hands-On Course in Sensors Using the Arduino and


Raspberry Pi 2nd Edition Volker Ziemann

https://ebookmeta.com/product/a-hands-on-course-in-sensors-using-
the-arduino-and-raspberry-pi-2nd-edition-volker-ziemann/
Arduino and Raspberry Pi Sensor
Projectsfor the Evil Genius™
Arduino and Raspberry Pi Sensor
Projects for the Evil Genius™

Robert Chin

New York Chicago San Francisco Athens London Madrid


Mexico City Milan New Delhi Singapore Sydney Toronto
Library of Congress Control Number: 201794884

McGraw-Hill Education books are available at special quantity discounts to use as premiums and sales
promotions or for use in corporate training programs. To contact a representative, please visit the Contact
Us page at www.mhprofessional.com.

Arduino and Raspberry Pi Sensor Projects for the Evil Genius™

Copyright © 2018 by McGraw-Hill Education. All rights reserved. Printed in the United States of America.
Except as permitted under the United States Copyright Act of 1976, no part of this publication may be
reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without
the prior written permission of the publisher.

McGraw-Hill Education, the McGraw-Hill Education logo, Evil Genius and TAB, and related trade dress
are trademarks or registered trademarks of McGraw-Hill Education and/or its affiliates in the United States
and other countries and may not be used without written permission. All other trademarks are the property
of their respective owners. McGraw-Hill Education is not associated with any product or vendor mentioned
in this book.

1 2 3 4 5 6 7 8 9 DSS 22 21 20 19 18 17

ISBN 978-1-260-01089-3
MHID 1-260-01089-9

e-ISBN 978-1-260-01090-9
e-MHID 1-260-01090-2

This book is printed on acid-free paper.

Sponsoring Editor
Michael McCabe
Editorial Supervisor
Donna M. Martone Production Supervisor
Lynn M. Messina

Acquisitions Coordinator
Lauren Rogers
Project Manager
Patricia Wallenburg, TypeWriting

Copy Editor
James Madru

Proofreader
Claire Splan

Indexer
Claire Splan
Art Director, Cover
Jeff Weeks

Composition
TypeWriting

Information contained in this work has been obtained by McGraw-Hill Education from sources believed to
be reliable. However, neither McGraw-Hill Education nor its authors guarantee the accuracy or
completeness of any information published herein, and neither McGraw-Hill Education nor its authors shall
be responsible for any errors, omissions, or damages arising out of use of this information.
About the Author

Robert Chin has a Bachelor of Science degree in computer engineering and is


experienced in developing projects on the TI CC3200 SimpleLink, Android,
Arduino, Raspberry Pi, and PC Windows platforms using C/C++, Java, Python,
Unreal Script, DirectX, OpenGL, and OpenGL ES 2.0. He is the author of Home
Security System DIY PRO Using Android and TI CC3200 SimpleLink, Home
Security Systems DIY Using Android and Arduino, and Beginning Arduino
ov7670 Camera Development. He is also the author of Beginning Android 3d
Game Development and Beginning IOS 3d Unreal Games Development, both
published by Apress, and was the technical reviewer for UDK Game
Development, published by Course Technology CENGAGE Learning. Beginning
Android 3d Game Development was licensed to Tsinghua University through
Tsinghua University Press.
Contents

1 Introducing the Arduino and Raspberry Pi


What Is an Arduino?
Arduino Uno
Arduino Uno Specifications
Arduino Uno Components
Arduino Development System Requirements
Arduino IDE Software
Hands-on Example:
A Simple Arduino “Hello World” Program with a LED
Playing Around with the Code
What Is Raspberry Pi?
Raspberry Pi 3 Hardware Overview
Raspberry Pi System Setup
Python IDLE Development Environment
Hands-on Example:
A Simple Raspberry Pi “Hello World” Program with a LED
Summary

2 Arduino and Raspberry Pi Programming Language Basics


Overview of the C/C++ Language for the Arduino
Object-Oriented Programming
Overview of Python for Raspberry Pi
Python Functions
Python Modules
Python Class Overview
Python Class Inheritance
Summary

3 Basic Electrical Components


Electronics Basics
Resistor
LEDs
Piezo Buzzer
Potentiometer
Push Buttons
Breadboards
Hands-on Example:
Arduino Serial Monitor and LED Indicator
Hands-on Example:
Arduino RGB LED
Hands-on Example:
Arduino LED Buzzer Siren
Hands-on Example:
Arduino Random RGB LED Colors Using a Potentiometer
Hands-on Example:
Arduino RGB Light Switch
Hands-on Example:
Raspberry Pi LED Blinker Counter
Hands-on Example:
Raspberry Pi LED Fading
Hands-on Example:
Raspberry Pi RGB LED Color Selector
Hands-on Example:
Raspberry Pi LED Fading Up and Down Using a Button
Summary

4 Touch Sensor Projects


Analog Joystick
Hands-on Example:
Arduino Joystick Test
Hands-on Example:
Arduino “Simon Says” Game
Running the Program
Rotary Encoder Controller (KY-040)
Hands-on Example:
Arduino Rotary Encoder Test
Hands-on Example:
Arduino Rotary Encoder Controlling an RGB LED
Hands-on Example:
Raspberry Pi Rotary Encoder Test
Hands-on Example:
Raspberry Pi Rotary Encoder LED Blinker
Summary

5 Environmental Sensor Projects I


Reed Switch Magnetic Field Sensor
Hands-on Example:
Arduino Reed Switch Test
Hands-on Example:
Arduino Door Buzzer Alarm
Hands-on Example:
Raspberry Pi Reed Switch Test
Hands-on Example:
Raspberry Pi Reed Switch Door Alarm
TMP36 Temperature Sensor
Hands-on Example:
Arduino TMP36 Temperature Sensor Test
Flame Sensor
Hands-on Example:
Arduino Flame Sensor Test
Hands-on Example:
Arduino Fire Alarm
Hands-on Example:
Raspberry Pi Flame Sensor Test
Hands-on Example:
Raspberry Pi Fire Alarm
Infrared Proximity/Collision Sensor
Hands-on Example:
Arduino Infrared Proximity/Collision Detector
Hands-on Example:
Raspberry Pi Infrared Collision/Proximity Sensor Alarm
Temperature and Humidity Sensor (DHT11)
Hands-on Example:
Arduino DHT11 Temperature and Humidity Sensor Test
Summary

6 Environmental Sensor Projects II


Water Detector/Soil Moisture Sensor
Hands-on Example:
Arduino Water Detector Alarm
Hands-on Example:
Arduino Soil Moisture Detector
Light Detector (Photo Resistor)
Hands-on Example:
Arduino Rooster Alarm
Sound Detector
Hands-on Example:
Arduino Light Clapper
Hands-on Example:
Raspberry Pi “Out of Breath” Game
Summary

7 Human Sensor Projects


Hands-on Example:
Arduino Glass Break Alarm
Hands-on Example:
Raspberry Pi Glass Break Alarm
HC-SR501 Infrared Motion Detector
Hands-on Example:
Arduino Infrared Motion Detector Alarm
Hands-on Example:
Raspberry Pi Infrared Motion Detection Alarm
HC-SR04 Distance Sensor
Hands-on Example:
Arduino HC-SR04 Distance Sensor Intruder Alarm
Hands-on Example:
Arduino Collision Alarm
Summary

8 Arduino TFT LCD Display and Image Sensor Projects


Arduino TFT LCD Color Display Screen with SD Card Reader/Writer
Hands-on Example:
Arduino TFT Display and SD Card Reader/Writer Test
Hands-on Example:
Arduino TFT Display Door Entry Alarm with SD Card Logging
Arduino Cameras
Hands-on Example:
Arduino ArduCAM OV2640 Mini Portable Programmable Digital Camera
System
Summary
Index
CHAPTER 1
Introducing the Arduino and Raspberry Pi

THIS CHAPTER WILL INTRODUCE YOU to the Arduino and the Raspberry Pi. First, I
give a brief explanation of what the Arduino is. Then I specifically address the
Arduino Uno, discussing its general features, including its capabilities and key
functional components. This is followed by a discussion of the Arduino
Integrated Development Environment (IDE) software, which is needed to
develop programs for the Arduino. Each key function of the Arduino IDE is
reviewed, followed by a hands-on example giving detailed step-by-step
instructions on how to set up the Arduino for development and how to run and
modify an example program using the Arduino IDE. Next comes the Raspberry
Pi. I discuss what the Raspberry Pi is and the specifications for the Raspberry Pi
3. This section tells you how to set up the Raspberry Pi before using it for the
first time. Raspberry Pi hardware features are addressed, including the general
purpose input-output (GPiO) pin specifications. The final section includes a
hands-on example of how to control a light-emitting diode (LED) using the
Raspberry Pi.

What Is an Arduino?
The Arduino is an open-source microcontroller that uses the C and C++
languages to control digital and analog outputs to devices and electronic
components and to read in digital and analog inputs from other devices and
electronic components for processing. For example, an Arduino can read a signal
from a sensor in a home security system that detects the heat that a human being
emits. The sensor sends a signal to the Arduino indicating that a person is in the
home. After receiving this information, the Arduino can send commands to a
camera such as the ArduCAM Mini digital camera to start taking pictures of the
intruder. There are many different Arduino models out there. However, to create
the examples in this book, you will need an Arduino model with enough pins to
connect the components you desire, such as a camera, Bluetooth adapter, and/or
motion sensor. Figure 1-1 shows the official Arduino logo.

Figure 1-1 Official Arduino logo.

Note: The official website of the Arduino is www.arduino.cc.

Arduino Uno
There are a great many Arduino products out there, ranging from models that are
small and can actually be worn by the user to models with many digital and
analog input-output pins. For the projects in this book, I recommend the Arduino
Uno, which is an open-source microcontroller that has enough digital ports to
accommodate a camera, a Secure Digital (SD) card reader/writer with enough
digital and analog ports for other devices, sensors, lights, and any other gadgets
that you may require for your own custom projects. The official Arduino Uno
board is made by a company called Arduino SRL, formerly Smart Projects,
formed by one of the founders of the Arduino (Figure 1-2). The newer official
Arduino Uno boards are slightly different in that they are more blue-green
instead of blue in color and contain the Genuino logo under the main Arduino
logo. The Genuino trademark is used outside the United States as a result of the
split between Arduino founders.
Figure 1-2 The official Arduino Uno.

There are also unofficial Arduino Uno boards made by other companies. A
good way to tell whether a board is official or unofficial is by the color of a
component that is located near the Arduino’s USB port. This component on an
official Arduino board is a metallic gold color. The component on an unofficial
board is green. The writing on the components also differs (Figure 1-3).
Figure 1-3 Metallic gold colored component on an official Arduino Uno board.

A number of other companies also manufacture Arduino Uno boards.


Because the Arduino is an open-source item, other companies can legally
manufacture the board, and the boards vary in quality and price. Generally, an
unofficial Arduino Uno costs around $10, and an official Arduino Uno costs
around $20. The distinguishing parts of an official Arduino board are the golden
component and the high-quality Arduino and Genuino logos printed on the board
(Figure 1-4).
Figure 1-4 Key parts of an official Arduino Uno.

Arduino Uno Specifications


Microcontroller: ATmega328P
Operating voltage: 5 V
Input voltage (recommended): 7–12 V
Input voltage limit: 6–20 V
Digital I/O pins: 14 (of which 6 provide PWM output) PWM digital I/O pins:
6
Analog input pins: 6
DC current per I/O pin: 20 mA DC current for 3.3-V pin: 50 mA Flash
memory: 32 kB (ATmega328P) (of which 0.5 kB used by boot loader)
SRAM: 2 kB (ATmega328P) EEPROM: 1 kB (ATmega328P) Clock
speed: 16 MHz Length: 68.6 mm Width: 53.4 mm Weight: 25 g

Arduino Uno Components


This section covers the functional components of the Arduino Uno.

USB Connection Port


The Arduino Uno has a USB connector that is used to connect the Arduino to the
main computer development system via standard USB A male to B male cable
so that it can be programmed and debugged (Figure 1-5).

Figure 1-5 USB connector.

9-V Battery Connector


The Arduino Uno has a 9-V battery connector where you can attach a 9-V
battery to power the Arduino (Figure 1-6).
Figure 1-6 Arduino Uno 9-V battery connector.

Reset Button
There is a Reset button on the Arduino Uno that you can press to reset the board.
This restarts the program contained in the Arduino’s memory (Figure 1-7).

Figure 1-7 Arduino Uno Reset button.

Digital Pins
The Arduino Uno has many digital pins capable of simulating analog output
through the process of pulse-width modulation (PWM). For example, a LED
light generally has only two modes: on (full brightness) and off (no light
emitted). However, with digital PWM, the LED light can appear to have a
brightness in between on and off. For instance, with PWM, a LED can start from
an off state and slowly brighten until it is at its highest brightness level and then
slowly dim until back to the off state. The digital pins on the Arduino Uno are
pins 0 through 13. These PWM-capable digital pins are circled in Figure 1-8.

Figure 1-8 Arduino Uno digital pins.

Communication
The communication section of the Arduino Uno contains pins for serial
communication between the Arduino and other devices, such as a Bluetooth
adapter or a personal computer. The Tx0 and Rx0 pins are connected to the USB
port and are used for communication between your Arduino and your computer
by means of a USB cable. The Serial Monitor that can be used for sending data
to the Arduino and reading data from the Arduino uses the Tx0 and Rx0 pins.
Thus you should not connect anything to these pins if you want to use the Serial
Monitor to debug your Arduino programs or to receive user input (Figure 1-9). I
will talk more about the Serial Monitor later in this book.
Figure 1-9 Arduino Uno serial communication.

The I2C interface consists of an SDA pin (which is pin 4) that is used for
data and an SCL pin (which is pin 5) that is used for clocking or driving the
device or devices attached to the I2C interface. The SDA and SCL pins are
circled in Figure 1-10.
Figure 1-10 Arduino Uno I2C interface.

Analog Input
The Arduino Uno has six analog input pins that can read in a range of values
instead of just digital values of 0 or 1. The analog input pin uses a 10-bit analog-
to-digital converter to transform voltage input in the range of 0 to 5 V into a
number in the range between 0 and 1,023 (Figure 1-11).
Figure 1-11 Arduino Uno analog input.

Power
The Arduino Uno has outputs for 3.3 and 5 V. One section that provides power is
located on the side of the Arduino. You can also provide a separate power source
by connecting the positive terminal of the power source to the Vin pin and the
ground of the power source to the Arduino’s ground. Make sure that the voltage
being supplied is within the Arduino’s voltage range (Figure 1-12).
Figure 1-12 Arduino Uno 3.3- and 5-V power outputs.

The ground connections on the Arduino Uno are shown circled in Figure 1-
13.
Figure 1-13 Arduino Uno ground connections.

Arduino Development System Requirements


Arduino projects can be developed on Windows, Mac, and Linux operating
systems. The software needed to develop programs that run on the Arduino can
be downloaded from the main website at www.arduino.cc/en/Main/Software.
The following is a summary of the different types of Arduino IDE
distributions that are available for download. You will only need to download
and install one of these files. The file you choose will depend on the operating
system your computer is using.

Windows
Windows Installer. This is an .exe file that must be run to install the Arduino
IDE.
Windows zip file for non-administrator install. This is a zip file that must be
uncompressed in order to install the Arduino IDE. 7-zip is a free file
compression and uncompression program available at www.7-zip.org that can
be used to uncompress this program.

An Important Note: For Windows XP, I recommend the 1.0.5 r2 version of the Arduino IDE.
Later versions may not be stable and may terminate unexpectedly, behave erratically, or
may not be able to compile Arduino source code.

Mac
Mac OS X 10.7 Lion or newer. This is a zip file that must be uncompressed
and installed for users of the Mac operating system.

Linux
Linux 32 bits. Installation file for the Linux 32-bit operating system.
Linux 64 bits. Installation file for the Linux 64-bit operating system.
The easiest and cheapest way to start Arduino development is probably by
using the Windows version on an older operating system such as Windows XP.
In fact, the examples in this book were created using the Windows version of the
Arduino IDE running on Windows XP. There are in fact many sellers on Ebay
from whom you can buy a used Windows XP computer for around $50 to $100.
If you are starting from scratch and are looking for an inexpensive development
system for the Arduino, consider buying a used computer with Windows XP. The
only caution is that support for Windows XP has ended in the United States and
some other parts of the world. In China, Windows XP may still be supported
with software updates such as security patches.

Arduino IDE Software


Arduino IDE is the program used to develop the program code that runs on and
controls the Arduino. For example, to have your Arduino control the lighting
state of a LED, you will need to write a computer program in C/C++ using the
Arduino IDE. Then you will need to compile the program into a form that the
Arduino is able to execute and then transfer the final compiled program using
the Arduino IDE. From there the program automatically executes and controls
the LED that is connected to the Arduino.
New versions of the Arduino IDE are compiled daily or hourly and are
available for download. Older versions of the IDE are also available for
downloading at www.arduino.cc/en/Main/OldSoftwareReleases.
This section discusses the key features of the Arduino IDE software. The
IDE you are using may be slightly different from the version discussed in this
section, but the general functions should still be the same. I won’t go in depth
into every detail of the IDE because this section is meant as a quick-start guide
and not a reference manual. I will cover the critical features of the Arduino IDE
that you will need to get started on the projects in this book (Figure 1-14).
Figure 1-14 The Arduino IDE.

The Verify button checks to see whether the program you have entered into
the Arduino IDE is valid and without errors (Figure 1-15). These uncompiled
programs are called sketches.
Figure 1-15 The Verify button.

The Upload button first verifies that the program in the IDE is a valid C/C++
program with no errors, compiles the program into a form the Arduino can
execute, and then finally transfers the program via the USB cable connected to
your computer to your Arduino board (Figure 1-16).

Figure 1-16 The Upload button.

The New File button creates a new blank file or sketch inside the Arduino
IDE, where you can create your own C/C++ program for verification,
compilation, and transfer to the Arduino (Figure 1-17).

Figure 1-17 The New File button.

The Open File button is used to open and load the Arduino C/C++ program
source code from a file or load various sample source codes from example
Arduino projects that are included with the IDE (Figure 1-18).
Figure 1-18 The Open File button.

The Save button saves the sketch on which you are currently working to
disk. A File Save dialog is brought up first, and then you will be able to save the
file on your computer’s hard drive (Figure 1-19).

Figure 1-19 The Save button.

The Serial Monitor button brings up the Serial Monitor debug program,
where you can examine the output of debug statements from the Arduino
program. The Serial Monitor can also accept user input that can be processed by
the Arduino program (Figure 1-20). I will discuss the Serial Monitor and how to
use it as a debugger and input console later in this book.

Figure 1-20 The Serial Monitor button.

The main window of the Arduino IDE also includes other important features.
The title bar of the IDE window contains the Arduino IDE version number. In
Figure 1-21, the Arduino version number is 1.0.5 r2. The sketch name is
displayed in the source code tab and is “Blink,” which is one of the sample
sketches that comes with the Arduino IDE. The source code area, which is the
large white area with scrollbars on the right side and bottom, is where you enter
your C/C++ source code that will control the behavior of the Arduino. The
bottom black area in the IDE is where warning and errors are displayed from the
code verification process. At the bottom left-hand corner of the IDE is a number
that represents the line number in the source code where the user’s cursor is
currently located. In the lower right-hand corner of the IDE is the currently
selected Arduino model and COM port to which the Arduino is attached.

Figure 1-21 The general IDE.


Hands-on Example:
A Simple Arduino “Hello World” Program with a
LED
In this hands-on example, I will show you how to set up the Arduino
development system on your Windows-based PC or Mac. First, you need to
obtain an Arduino board and USB cable. Then you must install the Arduino IDE
and Arduino hardware device drivers. Then I will show you how to load in the
“Blink” example sketch. I tell you how to verify that the program is without
syntax errors, how to upload it onto the Arduino, and how to tell whether the
program is working. Finally, I discuss how the Blink program code works and
show you how to modify it.

Get an Arduino Board and USB Cable


You can purchase an official Arduino Uno board from a distributor listed on
www.arduino.cc/en/Main/Buy or www.Arduino.org. The first website is still
generally considered the main website for Arduino. However, the second website
is run by the people actually making Arduino boards. The split among the
founders of the Arduino mentioned earlier can be seen here in terms of who is
designated as a distributor of an “official” Arduino board.
A second option is to buy an unofficial Arduino Uno made by a seller not
listed as an official distributor by either arduino.cc or arduino.org. These boards
are generally a lot cheaper than “official” Arduino boards. However, the quality
may vary widely between manufacturers or even between production runs of the
same manufacturer.
Official Arduino boards generally do not come with a USB cable, but many
unofficial boards do come with a short USB cable. Longer Arduino-compatible
USB cables (such as 6- or 10-foot cables) can be bought on Amazon.com or
eBay.com. I purchased a “Mediabridge USB 2.0 – A Male to B Male Cable (10
Feet) – High-Speed with Gold-Plated Connectors – Black” from Amazon.com
for my “official” Arduino Uno, and its seems to work well. Make sure that you
get the right kind of USB cable with the right connectors on each end. The
rectangular end of the USB cable is connected to your computer, and the square
end is connected to your Arduino (Figure 1-22).
Figure 1-22 Arduino USB cable.

Install the Arduino IDE


The Arduino IDE has versions that can run on Windows, Mac, and Linux
operating systems. The Arduino IDE can be downloaded from
www.arduino.cc/en/Main/Software. I recommend installing the Windows-
executable version if you have a Windows-based computer. Follow the
directions in the pop-up windows.

Note: The Arduino website also contains links to instructions for installing the Arduino IDE
for Windows, Mac, and Linux at www.arduino.cc/en/Guide/HomePage. The installation for
Linux depends on the exact version of Linux being used.

Install the Arduino Drivers


The next step is to connect your Arduino to your computer using the USB cable.
If you are using Windows, it will try to automatically install your new Arduino
hardware. Follow the directions in the pop-up windows to install the drivers.
Decline to connect to Windows Update to search for drivers. Select “Install the
software automatically” as recommended. If you are using XP, ignore the pop-up
window warning about the driver not passing Windows logo testing to verify its
compatibility with XP.
If this does not work, then instead of selecting “Install the software
automatically,” specify a specific driver location, which is the “drivers/FTDI”
directory under your main Arduino installation directory.
Load the “Blink” Arduino Sketch Example
Next, we need to load the “Blink” sketch example into the Arduino IDE. Click
the Open file button to bring up the menu. Under “01. Basics,” select the “Blink”
example to load (Figure 1-23).

Figure 1-23 Loading the “Blink” sketch.

The code that is loaded into the Arduino IDE should look like the code in
Listing 1-1.

Listing 1-1 ”Blink” Sketch


/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.


// give it a name:
int led = 13;

// the setup routine runs once when you press reset:


void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Verify the “Blink” Arduino Sketch Example


Click the Verify button to verify that the program is valid C/C++ code and is
error-free (Figure 1-24).

Figure 1-24 Verifying the “Blink” sketch.

Upload the “Blink” Arduino Sketch Example


Before uploading the sketch to your Arduino, make sure the type of Arduino
under the “Tools > Board” menu item is correct. In our case, the board type
should be set to be “Arduino Uno” (Figure 1-25).

Figure 1-25 Set the Arduino type to “Arduino Uno.”


Next, make sure that the serial port is set correctly to the one that is being
used by your Arduino. Generally, Com1 and Com2 are reserved, and the serial
port to which the Arduino will be connected is Com3 or higher (Figure 1-26).

Figure 1-26 Set the serial (Com) port.

If you are using a Mac, then the serial port selection should be something
like “/dev/tty.usbmodem” instead of a COMxx value.
Next, with the Arduino connected, press the Upload button to verify,
compile, and then transfer the “Blink” example program to the Arduino. After
the program has finished uploading, you should see a message that the upload
has been completed in the Warnings/error window at the bottom of the IDE
inside the black window (Figure 1-27).

Figure 1-27 Upload to the Arduino.

Note: The Upload button does the job of the Verify button and also uploads the final
compiled program to the Arduino.
Final Result
The final result will be a blinking light on the Arduino board near digital pin 13.
By design, the Arduino board has a built-in LED connected to pin 13. So this
example did not require you to connect an actual separate LED to the Arduino
board (Figure 1-28).

Figure 1-28 Built-in LED.

Playing Around with the Code


The default of the program is to turn on the LED for 1 second and then turn it off
for 1 second. The code that controls the timing is located in the loop() function.
The digitalWrite() function sets the variable LED, which is pin 13, to either
on, which is HIGH, or off, which is LOW. The delay() function suspends
execution of the program for 1,000 milliseconds, or 1 second, so that the LED is
set on for 1 second and off for 1 second (Listing 1-2).

Listing 1-2 loop() Function


void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Play around with the values in the delay() functions, lengthening or


shortening the time the LED stays on and/or lengthening or shortening the time
the LED stays off. For example, to have the LED flash briefly, shorten the first
delay value to 100. This will shorten the time that the LED stays on. Upload the
new sketch to the Arduino by pressing the Upload button. After it has finished
uploading, you will see a message in the black Warnings/error message window
at the bottom of the IDE. Look at the LED on the Arduino. The timing of the
LED on/off pattern should have changed.

What Is Raspberry Pi?


Raspberry Pi is a small, inexpensive computer based on the Linux operating
system. The computer itself sells for around $35 and was originally designed as
a learning tool to get young people and students interested in pursuing a career in
computer programming. The official website for the Raspberry Pi is located at
www.raspberrypi.org.

Raspberry Pi 3 Model B
Many models of the Raspberry Pi have been produced, but the type of Raspberry
Pi that I will use in this book is the newest and most popular Raspberry Pi: the
Raspberry Pi 3 Model B. This model replaces the Raspberry Pi 2 and is
recommended for use in schools and for general purpose use. For those who
want to embed a Raspberry Pi as part of a larger project or require a Raspberry
Pi that uses low power, then the Raspberry Pi 0 or Model A+ is recommended.
The specifications of the Raspberry Pi 3 Model B are as follows:
1.2-GHz 64-bit quad-core ARMv8 CPU
802.11n wireless LAN
Bluetooth 4.1
Bluetooth Low Energy (BLE) 1-GB RAM
Four USB ports 40 GPiO pins Full HDMI port Ethernet port Combined
3.5-mm audio jack and composite video Camera interface (CSI) Display
interface (DSI)
Micro SD card slot (now push-pull rather than push-push) VideoCore IV 3D
graphics core

Raspberry Pi 3 Hardware Overview


The Raspberry Pi 3 is manufactured as a small single board similar to the size of
a credit card without a case containing all the above-mentioned components
(Figure 1-29).

Figure 1-29 Top view of the Raspberry Pi 3 hardware layout.

The Raspberry Pi 3 consists of the following major components, which are


labeled in Figure 1-29 as:
Item 1: Two USB ports stacked on top of each other Item 2: A second set of
two USB ports stacked on top of each other Item 3: Ethernet socket for
connecting to a network router Item 4: A 3.5-mm jack for audio and video
output to a monitor or television Item 5: An MIPi camera serial interface
(CSI) Item 6: A High Definition Multimedia Interface (HDMI) port for
video output to a monitor or television Item 7: GPiO pins that will be used
to connect sensor devices to the Raspberry Pi in this book Item 8: A Display
Serial Interface (DSI) that is used to connect the Raspberry Pi to a liquid-
crystal display (LCD) Item 9: A micro USB socket used for power input to
the Raspberry Pi
The bottom of the Raspberry Pi 3 contains a micro SD card reader/writer that
serves as a storage device like a hard drive would on a desktop computer. The
micro SD stores the Raspberry Pi’s operating system, program applications, and
data generated by the program applications and the user. On the Raspberry Pi 3,
the micro SD card reader/writer is of the push-pull type. This means that you
will need to push the SD card into the slot to have the SD card be read from and
written to, and then you will need to pull the card out to remove it from the SD
card slot (Figure 1-30).

Figure 1-30 Bottom view of the Raspberry Pi 3.

With the Raspberry Pi oriented like the one in Figure 1-29, the GPiO pin
specifications are as shown in Figure 1-31.
Figure 1-31 Raspberry Pi 2 and Raspberry Pi 3 GPiO pin numbering.

The symbols on the pins denote the following:


5V: This is a 5-V output source from the Raspberry Pi that can be used to
power your custom circuit.
3.3V: This is a 3.3-V output source from the Raspberry Pi that can be used to
power your custom circuit.
G: Ground pin.
EE: EEPROM-related pin (which will not be used in this book).
Number: This is the number of the GPiO pin.

Raspberry Pi System Setup


This section will tell you what you will need to set up your Raspberry Pi
computer system and how to perform the actual setup. At the bare minimum,
you will need
A Raspberry Pi 3 board A USB keyboard A USB mouse A micro USB
power adapter that can provide 2.5-A power An HDMI-compatible monitor
or TV (which I recommend) or a monitor with composite inputs or a VGA
monitor and an HDMI-to-VGA adapter (I recommend an HDMI monitor
because it provides sharp resolution and sound output. The composite output is
of a lower-quality resolution, and using a VGA monitor with a Raspberry Pi
requires you to make some changes to the Raspberry Pi’s configuration file.)
A micro SD card with new out of box software (NOOBS) on it Preferably
some kind of case for your Raspberry Pi 3 board to protect it against static
electricity and small spills of liquid
If you are just beginning in Raspberry Pi development, then I recommend
that you get one of the Raspberry Pi 3 starter kits, which are widely available
online on such websites as Amazon.com. Many of the starter kits have all of the
items listed above. In addition, if you do not have an HDMI monitor, you can
usually find a small one for around US$50 on Amazon.com. These monitors are
generally around 10 inches in display size and can be used as portable monitors
for your Raspberry Pi 3 system.
To start using your Raspberry Pi, you should
1. Connect the keyboard, mouse, and HDMI monitor to your Raspberry Pi.
2. Insert your SD card with the NOOBS into the Raspberry Pi’s micro SD card
reader/writer.
3. Turn on your Raspberry Pi by plugging in the micro USB power adapter. An
important thing to note is that the Raspberry Pi does not have an on/off switch.
4. The NOOBS setup program will start running. This program will install the
actual Raspberry Pi operating system, which is called Raspbian. Follow the
directions that appear on the screen to install the software. You should see a
pop-up window that looks like the one shown in Figure 1-32. Check the box
next to the Raspbian selection, and click on the Install button.

Figure 1-32 The NOOBS operating system installation screen.

Python IDLE Development Environment


The programming language that we will be using in this book for projects
involving the Raspberry Pi is the Python programming language. The Raspberry
Pi has a Python development environment called IDLE. IDLE provides you with
a read-evaluate-print-loop (REPL) that allows you to continuously enter Python
statements and have them executed by the Python language. The output of these
statements is also displayed within IDLE. You can start the Python IDLE
program by clicking on “Python 3” under the Menu > Programming menu
(Figure 1-33).

Figure 1-33 The Python 3 development environment.

From within the IDLE program you can also create and save new files. An
alternative to using IDLE to create Python programs is to use a text editor such
as Vim, Nano, or LeafPad and execute the Python program by typing “python
filename.py” on the command line.

Hands-on Example:
A Simple Raspberry Pi “Hello World” Program
with a LED
This section presents a simple hands-on example of creating a blinking LED
using the Raspberry Pi 3.
Parts List
For this hands-on example, you will need
One LED
One breadboard Two wires with one end having a female plug to connect to
the Raspberry Pi’s GPiO pins and the other end having a male plug to connect
to the breadboard

Setting Up the Hardware


1. Insert the short leg of the LED, which is the negative side, into a hole on the
breadboard.
2. Insert the long leg of the LED, which is the positive side, into a different hole
on the breadboard that is disconnected from the node in step 1. Note:
Breadboards generally have horizontal rows of nodes of about five holes each
that are connected together. Some breadboards have a positive row of holes
that are connected together and a negative row of holes that are connected
together.
3. Attach a wire from a ground pin on the Raspberry Pi to the ground node on the
breadboard that contains the negative side of the LED.
4. Attach a wire from GPiO pin number 14 to the node on the breadboard that
contains the positive side of the LED.

Figure 1-34 shows a simplified graphic representation of how to hook the


LED up to the Raspberry Pi 3 board.
Figure 1-34 Blinking LED on a Raspberry Pi 3 board.

Setting Up the Software


Now you will need to set up the software that will run on the Raspberry Pi itself
to control the hardware you just set up. In order to control the blinking of a LED
from the Raspberry Pi, you need to do the following:
1. Import the LED class from the gpiozero library.
2. Import the sleep function from the time library.
3. Create a new LED object that is connected to GPiO pin 14, and then assign
this object to the led variable.
4. Execute the following in an infinite loop: a. Turn the LED on by calling the
led.on() function.

b. Wait for 1 second by calling the sleep() function with 1 as a parameter.


c. Turn off the LED by calling the led.off() function.
d. Wait for 1 second by calling the sleep() function with 1 as a parameter.
See Listing 1-3.

Listing 1-3 Blinking LED


from gpiozero import LED
Another random document with
no related content on Scribd:
and the American twist he had managed to acquire to his tongue.
However, that is not especially important. Go on, sergeant.”
“I, Pepernik, Louis Minowsky,” read Cato, “and Maurice Matschka.”
“Maurice Matschka!” The officer sprang to his feet. “That is a link
worth looking into,” he muttered. “Come on!” He caught up his hat,
and gave a quick nod of the head toward Cato. “I am going to the
city hall.”
Arriving at the municipal building, and proceeding to police
headquarters, he was directed, on inquiry, to a certain Detective
Krause, as having the case of the murdered Japanese in charge.
“What makes all you people out at the fort so interested in this
affair, anyhow?” the detective asked, with a curious glance at Grail.
“Major Appleby and Lieutenant Hemingway was over here before
supper, and I told them all there was to know. The best I can do for
you, captain, is just to go over the same ground.”
“Of course,” Grail assented, with a smile. “Still you know how it is,
Mr. Krause; every one wants to hear a story at firsthand; and, as I
was, perhaps, better acquainted with poor Sasaku than any of the
other officers at the mess, there is just a possibility that I may be
able to throw some light on the tragedy.”
As a matter of fact, the detective required very little urging. He had
come to such an absolute halt in the investigation that he was only
too willing to repeat the story to any one who offered even the
faintest show of providing a solution.
His recital, though, if somewhat more diffuse, was practically the
same as that which Grail had already read in the newspaper. He
presented nothing new in the way of any material details.
“H’m!” The adjutant thoughtfully stroked his chin at the completion
of the narrative. “There would be no objection, I suppose, to letting
me examine the notebook which you say was found on Sasaku?”
“Certainly not, sir.” He stepped away to get it, adding, as he
returned and handed it over: “You won’t find anything there to help
you, captain. We’ve been over it already with a fine-tooth comb, and
it seems nothing but a list of names and people he’d met; some of
them in the city directory, and some not.”
Grail, however, evidently preferred to decide this point for himself;
for slowly and painstakingly he ran over the pages, scrutinizing each
entry carefully before he passed on to the next.
The detective, fidgeting at what he manifestly regarded as wasted
time, presently excused himself, on the plea of wanting to do some
telephoning, and sauntered off, and, with his going, Grail turned back
a couple of pages to point out significantly to Cato the name of
Dabney, with a little, almost indistinguishable mark set opposite it.
No further discovery was elicited until they reached the last page;
then Grail gave a sudden start, as he read, with the same cabalistic
mark against it, the name of Rezonoff.
“Rezonoff!” he muttered, with a frown of grave foreboding. “That
can only be Count Boris Rezonoff, captain in the imperial engineers!”
Cato, gathering from his tone that something was seriously wrong,
edged up closer.
“Is it bad, sir?” he whispered.
Grail vouchsafed no answer, but stood silent a moment, the look of
apprehension growing on his face; then snapped open his watch and
glanced at the time.
“Too early, by far,” he commented, under his breath. “I shall have
to wait at least two hours yet.”
Meanwhile, Cato, glancing over his shoulder, had been reading
down the page of the notebook, and now he gave a quick
exclamation.
“There’s another name with that same mark against it,” he
breathed excitedly. “Don’t you see it! Down there at the bottom,
underneath your thumb!”
But Grail, as though recalled to himself, sharply closed the book.
“Oh, that one is of no consequence,” he insisted; yet he knew that
it was, for he had already noted the name with the telltale check
opposite.
In Sasaku’s stiff, angular handwriting was set down: “Mrs. Otto
Schilder!”
TO BE CONTINUED.
THE NEGRO AND THE HORSE.
There is a time for everything, and the secret of success in life lies
in doing things at just the right minute.
A veterinary surgeon had occasion to instruct a colored stableman
how to administer medicine to an ailing horse. He was to get a
common tin tube—a bean blower—put a dose of the medicine in it,
insert one end of the tube into the horse’s mouth, and blow
vigorously into the other end, and so force the medicine down the
horse’s throat.
Half an hour afterward, the colored man appeared at the surgeon’s
office, looking very much out of sorts.
“What is the matter?” inquired the doctor, with some concern.
“Why, boss, dat hoss, he—he blew fust!”
THE NEWS OF ALL NATIONS.
Story of “Scotty” Hero of Zinc Fields.
Picture a man who has been badly bent at times—aye, even broke
unto the last jitney—one who has tasted the bitter things of life along
with the sweet, one who has seen a fortune swept away in a
twinkling, only to be regained after a long, persistent struggle.
Picture a good loser, who has lost more than most men will ever
earn, and who pins his faith in the mining industry to such an extent
that he laughs at failure and hangs on like a bulldog until he
succeeds, and you have a mind’s-eye view of J. M. Short, the best
known operator in the mining district near Joplin, Mo.—the “Scotty”
of the zinc fields.
Thirty-two years ago Short was working for $1.25 a per day at
Galena, Kan., and a few years later moved to Joplin, landing here
with the price of one ham sandwich. He worked for low wages until
he had saved enough to buy a prospect drill, and decided to look for
ore on his own responsibility.
His first few holes were blanks; the cost of sinking them was
heavy, considering Short’s limited finances. For a time it looked as
though he was destined to go back to wages. However, he hung on
until almost his last penny was gone; then luck smiled on him, and
he made his first strike. He had been watching the drill clippings for
so long and finding only barren pieces of rock that he could hardly
believe the truth when at last the sand bucket brought up a quantity
of yellow-looking dirt, rich in zinc ore.
Short sold this “prospect” for $5,000 cash, and immediately
invested the whole amount in what was known as the Bunker Hill
Mine, which netted him $65,000 in eighteen months, part of which—
$3,000—he reinvested in the Sacagawea Zinc Company, from which
he profited, inside of three months, to the tune of $17,000 more. A
year later Short again became “dead broke” on another mining
venture, and again went to work for wages.
Depriving himself of all luxuries and many necessities, he
continued to work for wages until he had saved up $1,800, when he
determined to again “try his hand.” One day, during an extremely dry
summer, he was driving by a piece of land where the Sitting Bull
Mine was later developed. He noticed a man sinking a hole to get
water at a point where a spring had once been. The land was low
and boggy and the digger was taking out shale and soapstone. The
formation looked good to Short, and he at once procured a forty-acre
lease from the owner. With $1,800, his sole capital, Short drilled the
ground, discovered a rich run of ore, and put down a shaft to the
185-foot level. The owner of the land put up the capital for building a
$15,000 mill. Ninety days later Short had paid for the mill, had
$10,000 in the bank to his credit, and had a vast body of ore blocked
out which netted him more than $100,000 in profits in the next few
months.
Almost immediately he secured another lease and opened up
what is known as the Pocahontas Mine, from which he cleared
another $100,000. Then followed in quick succession the Geronimo
and the Waneta-Pearl. Short is now interested in, if not the entire
owner of, more than a dozen valuable properties, so that, with the
sudden jump in price of zinc concentrates from thirty-five to seventy-
five dollars per ton, this Scotty of the zinc mines has but faint idea of
what he is really worth.

Talk is Cheap.
A retired United States army officer says the European war is “a
horrible slaughter, which should be halted by some neutral power.”
The neutral power that attempted to halt it forcibly would simply
increase the slaughter and add its own blood to the crimson tide.

Canada Spends Millions on Ports.


Canada is making extensive improvements in her seaports. At
Halifax work is under way which will cost $10,000,000, while at St.
John, New Brunswick, $8,000,000 is being spent. Levis, opposite
Quebec, is building the largest dry dock in America. Much work is
also being done at the Pacific coast ports.

Finds Petrified Snake in Rock.


While blasting some limestone rocks in the side of Stone
Mountain, near Big Laurel, Va., the workmen found a petrified snake
imbedded in the rocks. The snake was coiled as if making ready to
spring at something, and is believed to have been a copperhead.

Failures.
Commercial failures in the United States last year were 8,344.

Cossacks Rescue Little Girl.


A little incident, told in Danish newspapers which have arrived in
Chicago, shows that the Cossacks are not as cruel as they are
sometimes depicted. Recently while advancing against a
detachment of Turks, a company of Cossacks found a little girl, two
years old, who had been deserted by her parents in their precipitate
flight. They brought the little one to the headquarters of the regiment,
where she received food and was made comfortable in every way.
In the Greek Catholic Church in the village of Bardus the little
foundling was baptized according to the orthodox ritual. The
commander of the regiment and Princess Gelovana, wife of a
member of the Duma, served as godparents of the child. The little
girl received the name of Alexandre Donshaga, after the regiment
known as Don Cossacks. The officers promised to contribute
monthly toward the maintenance and education of this little
“daughter of the regiment.”
Girl in Soldier’s Uniform.
People in the vicinity of Cooke’s Church, on Queen Street, in
Toronto, at two-thirty in the afternoon were left wondering whether
the Germans had landed in the city in such large numbers that the
military authorities had found it necessary to mobilize a regiment of
the fair sex to aid the soldiers in driving them back.
The cause of the sensation was a pretty young lady named Clara
Philip, who, by the terms of a wager she had made with a lady friend,
had to walk down Mutual Street from Shuter to Queen Street
dressed in full soldier’s uniform, for a box of chocolates.
The young lady with curly hair peeping out under the service cap,
looked bewitching in the uniform, although it was somewhat too large
for her, and despite the fact that the heavy army boots were
dispensed with for her own dainty pair of “threes.”
“It certainly did feel funny walking down the street with some of the
people turning up their noses at me and others convulsed in
laughter, but I was determined to win the bet, and did,” said Miss
Philip, after her sensational parade.
“Oh, it was funny. On the way along I had the pleasure of saluting
a ‘brother’ soldier, who with much grace returned the salute, and a
little farther along a ‘guardian of the law’ discreetly turned and
walked in the opposite direction. That is the way I became richer by
a large box of chocolates.”

Sings as Surgeons Operate.


Zouave Besson, a French trooper, while undergoing an operation
at the Grand Palais, in Paris, a hospital for the last three months,
lustily sang the “Marseillaise” from the beginning to the end,
weakening slightly toward the close of the last stanza.
This patriotic demonstration is a contradiction of the proverb that a
good man will swear while he is under the influence of chloroform.
After the operation Besson’s nurse told him of his patriotism in
singing the national anthem.
He replied: “When I was just going on I realized that I was singing
the ‘Marseillaise,’ and brought all my will power to bear to sing it to
the end.” He recovered nicely.

Death of a Spy.
Death to all spies is the military rule. One of the most dramatic of
the many minor tragedies of the war was seen at Lassigny recently,
when a captive in a black gown, to all appearances a nun, was
suddenly led before a firing squad and shot down at the officer’s
command. The startled onlookers learned that the squad’s victim
was a daring young lieutenant in the German army who had got
inside the French lines by donning a nun’s attire. So good was his
disguise that he had gone for a considerable distance and probably
had obtained much information that would have proved valuable had
he escaped.
Had the spy been a woman, the penalty would have been the
same. Such is the law of war. Many women spies have been caught
and executed.

Oldest Veteran in Southwest Section.


Probably the oldest, and surely the most noted Confederate
veteran now living in the Southwest is Doctor Thomas E. Berry, of
Oklahoma City, Okla., a typical “Kentucky colonel,” who is now
eighty-three years old. He walks as straight as a young Indian, has
never used intoxicating beverages or tobacco and has never
suffered from fever or other sickness, and during his long and
eventful career he has been soldier, globe trotter, author, duelist,
physician, and surgeon.
In the Civil War he served with the Confederate generals, Morgan
and Forest, was captured twelve times by the Yankees, and escaped
that many times from their prisons. He received twenty-two bullet
wounds and several saber cuts during the four years of fighting, and
since the close of the war has fought six duels in foreign lands.
Doctor Berry served under Joe Shelby in Mexico and helped to
organize the French army in Algeria. He rendered valuable service to
King Menelik in Abyssinia and sojourned for a while in
Constantinople, where, like many others, he swam across the
Bosporus. He received several decorations from foreign rulers, but
never wears them in this “land of the free.”
In a recent chat with a friend Doctor Berry said:
“My father and grandfather admonished me to never forgive or
forget an insult; never offer the left cheek after having been slapped
on my right cheek. They also requested me to always keep the Berry
escutcheon untarnished; never be a craven nor a coward.”
The doctor comes from a wealthy family that owned large areas of
land near Perryville, Ky., but the Civil War made them comparatively
poor. The doctor wrote a book entitled “Four Years With Generals
Forest and Morgan.” He is now writing a book about his foreign
military service.
He has also made several valuable discoveries in materia medica
and surgery while practicing medicine forty years. Some of them are
very original and should not be allowed to perish with the doctor’s
death.
Doctor Berry, though one of the best physicians and surgeons, quit
practicing four years ago. He is an inveterate reader and has read
2,000 books. He also enjoys newspapers and magazines. It is
needless to say that the doctor’s personal appearance and
courteous manners denote him to be a gentleman and scholar. He
belongs to no religious sect, but is what he terms a “practical
Christian.” He will no doubt be as brave when Death calls him as he
always has been during his long life. The doctor is optimistic,
however, and says he will probably live to be a centenarian.

Some Facts You May Not Know.


The highest speed ever attained by man on the face of the earth is
one mile in 25.2 seconds, equivalent to 142.85 miles an hour,
according to the Railway Age Gazette. It was in an automobile run
by Teddy Tetzlaff on the level salt beds at Salduro, Utah, 112 miles
west of Salt Lake City. The best speed ever made on rails was with
an electric car between Berlin and Zossen, Germany, 130.5 miles an
hour.
Birds, in the construction of their nests, almost without exception
avoid bright-colored materials, which might possibly lead to the
discovery of their place of abode by an enemy.
Apple wood, used almost exclusively for saw handles, also
furnishes the material for many so-called brierwood pipes.
On a peace footing the Portuguese army consists of 32,000 men.
When fully mobilized, the army should have 105,000 first-line troops
and 145,000 of the second to put into the field.
In Germany, one man in 213 goes to college; in Scotland, one in
520; in the United States, one in 2,000, and in England, one in
5,000.
Damage to American crops by insects yearly amounts to
$580,000,000.
There are fewer suicides among miners than among any other
class of workmen.
A booby is not merely a human dunce, but is a Bahama bird,
which is so spiritless that when attacked by other birds it fails to fight
and gives up the fish it has caught without resistance.
Drawings of human beings and animals in ancient caves in France
are regarded as proof that man was right-handed as far back as in
the stone age.

Taking Precautions.
A rosy-cheeked youngster, dressed in his best clothes, entered the
village post office and carefully laid a huge slice of iced cake on the
counter.
“With my sister’s, the bride’s, compliments, and will you please eat
as much as you can,” he said.
The postmistress smiled delightedly.
“How very kind of the bride to remember me!” she cried. “Did she
know of my weakness for wedding cake?”
“She did,” answered the youngster coldly, “and she thought she’d
send over a bite of it this afternoon just to take the edge off your
appetite before she posted any boxes off to her friends.”

Kitchner’s Caustic Comment.


A story is going the rounds about what Lord Kitchener, the British
war secretary, said the other day after he had inspected some
defense works on the east coast of England. It is short and sweet.
The war minister motored from point to point, walked over the
ground, but never said a word all afternoon until the moment he was
leaving for London. Then he opened his grim mouth.
“Those trenches of yours,” he said, “wouldn’t keep out the
Salvation Army.”

Many Wolves in Texas.


The people of Texas destroyed 98,600 wolves and wild cats—
including fifty-three panthers and twenty-two leopards—between
September 1, 1912, and March, 1914, according to the State
comptroller. But there are many thousands more of these wild beasts
still alive, a serious menace to the rapidly growing industry of sheep
and Angora-goat raising.

Bandit Starr is Second Robin Hood.


Is Henry Starr, of Lawton, Okla., the bandit chief, another Robin
Hood? Does he, while engaged in robbing banks, keep in mind the
hardships of the poor, as did the picturesque highwayman and
poacher of early England? If only a part of the stories told of Starr
are true, he might be called the “Robin Hood of Oklahoma,” although
just now he is in Lincoln County Jail at Chandler, suffering from a
broken leg, and with a long prison term pretty thoroughly mapped out
for him. But here is what some of his admirers say he did:
“These things are of no value to me, but I’d hate it if the farmers
had them to pay,” and with that remark Henry Starr, the bandit leader
who, with his band of desperadoes, robbed two banks at Stroud and
was shot down and captured by eighteen-year-old Paul Curry, once
threw a heavy bundle of mortgages and notes, with a stone tied to
them, into California Creek in Northern Oklahoma, and they were
never recovered. Starr and his men had taken the bank’s papers
when they rifled the bank at Caney, Kan., several years ago, and he
said he took them just so the farmers would not have them to pay.
This incident in Starr’s bandit career was told by a long-time
resident of the Cherokee country. He has known Starr for a number
of years, has played poker with him frequently, and he insists that
Starr is really one of the kindliest of men. After the Kansas robbery
the Starr gang rode into northern Oklahoma and hid for some time,
and it was at this time that the mortgages and notes were destroyed.
The total value of the papers was perhaps never known, but a man
who saw them declares the bundle was a foot thick.
It was following this same robbery, too, that Starr made one of his
most spectacular get-aways. He and two men rode into an isolated
community during the night and concealed themselves in a big stone
barn, which was on the edge of a small valley with hills not far distant
and almost surrounding it. Starr and his men slept until late in the
day and then played pitch and shot craps for the small change they
had obtained at the bank. They would shoot for a handful of the
small silver, dimes and quarters, without any attempt being made to
ascertain the amount.
The whereabouts of Starr and his two companions became known
to the county sheriff, who, with a posse of twenty or thirty men, went
to the barn with the intention of capturing the trio. The members of
the posse were stationed on the hills surrounding the barn, and they
thought it would be impossible for the outlaws to escape. When Starr
was notified of the presence of the officers, he went into the
barnyard and motioned to the sheriff, whom he knew, to confer with
him. When the sheriff rode into the yard, Starr shook hands with him
as though he was glad to meet an old friend, and then said:
“I am going to leave here at five o’clock; there are three of us. If
you do not want your men hurt, you had better get them out of the
way, for when we start we are going through your lines. Tell your
men that for me.”
The sheriff returned to his men, called them together, and told
them what Starr had said; within five minutes there was not a man
other than the sheriff left within rifle distance of Henry Starr. That
evening at five, as he had announced, Starr and his men rode
quietly, and without being molested, away from the barn and toward
the Osage Hills.
That Starr’s wife was the original of a photograph, “The Cherokee
Milkmaid,” which was published worldwide several years ago, is the
statement of Representative Walter R. Eaton, of Muskogee and
Oilton. Eaton was engaged at that time in promoting the town site of
Porum, and was going through the country in that vicinity with a
photographer getting pictures to advertise that section.
Late one evening Eaton and the photographer drove by the home
of Mrs. Starr, Henry’s mother, at a time when a very pretty young
woman was milking a cow in the barnyard. The entire scene was one
that would make a beautiful picture, and the two men finally
persuaded the young woman to pose for several pictures.
“We got one fine picture,” said Eaton, “which we labeled ‘The
Cherokee Milkmaid.’ It attracted instant attention because of its
artistic merits and was published widely throughout the United States
in both newspapers and magazines. It was about a year afterward
that this young woman married Henry Starr.” Eaton says the young
woman was a school-teacher at the time and was boarding at the
Starr home.

Boy Hero Saves Five Lives.


The heroism of Aaron S. Ashbrook, twelve years old, saved the
lives of his mother, his grandmother, two sisters, and his uncle,
George Ashbrook, when they were trapped in the second story of
their burning home in Cynthiana, Ky.
Escape was cut off by means of the stairway, and the little fellow
leaped from the second-story window, and, running to a barn,
secured a ladder, which he placed to the window, and the inmates of
the house escaped without injury, with the exception of Mrs. Mary
Gray, the aged mother of Mrs. Ashbrook, who fell from the ladder
and was badly injured. The house was totally destroyed.

Town of 4,000; No Post Office.


Although boasting of a population of almost 4,000, and with mail
business sufficient, it is said, to justify free delivery, Oilton, Okla., the
recent metropolis of the Cushing oil field, has no post office.
Residents have chipped in and employed men to sort the mail, while
some concerns have employed their own carriers.
Two months ago Oilton was an alfalfa field. To-day it is one of the
fastest-growing towns in the country. It is the southern terminus of
the recently completed Oil Belt Terminal Railroad.
It is a great sight when the mail comes in. If it is not raining, the
mail is sorted out in piles on the ground. Usually the entire populace
stands around watching the assorting of the mail.
The post office department has been requested to designate a
post office at Oilton.

Builds Town Near His Farm.


Because he raised 150,000 bushels of wheat in 1914 and needed
a place to market it without a haul of ten miles, Ben Foster, a large
land owner, of Colby, Kan., built a town of his own. He constructed
an elevator, a coal and lumber yard, and some houses to go with it.
The town was named Breton.

Boy Flags and Saves a Train.


An attempt to wreck an east-bound Chesapeake & Ohio Railroad
passenger train, near Eastbrook, W. Va., was frustrated by a boy,
who flagged the train in time to prevent it from running into an
obstruction placed on the track. A pile of ties had been placed on the
track at the end of a curve. Railroad police are investigating.

Boston Has Giant Lobster.


The great-great-grandfather of all lobsters—according to Mike
O’Donnell, who is an authority on such matters—has arrived in
Boston, Mass. It is on exhibition in a stall in the Quincy Market.
The lobster, which in its natural state weighed thirty-three pounds
and one ounce, measures forty-two inches from the tip of its tail to
the end of its giant claws, the body alone measuring twenty-three
and one-half inches. Since arriving here the lobster has been boiled,
the meat removed, and the shell painted so that it now looks much
the same as it did when it left the waters of Newfoundland.
This giant lobster, the biggest one ever seen here, according to
some authorities, and one of the biggest on record, was caught off
Grand Manan by a fisherman named John Moses.

Buy-a-Pig Movement, Latest.


Isn’t it about time to buy a pig? This is no joke. One of the causes
of the high cost of living is in the fact that society is growing faster
than the farmers. There is no more profitable animal than a pig. He
improves the dressing and gives the gardener a valuable asset to
begin the season with. He stands in the doorway to keep the wolf
away through the winter. And the social part of it is no small item.
The pig is the most social of animals, especially when he is hungry,
and a good pig has a continuous appetite. It is no disgrace for any
one to raise a pig—not even a school-teacher. Buy a pig and get
your name on the roll of honor.

Motor Saw for Felling Trees.


In attempting to develop an electrically operated device for
bucking and felling trees, a lumber company in Marshfield, Ore.,
constructed a portable motor-driven chain saw, which will cut through
a two-foot log in less than a minute, declares the Electrical World.
The cutting element consists of a motor-driven saw-toothed chain
traveling around the peripheries of two pulleys, one at each end of
the frame. The motor is connected direct to one of the pulleys and is
supplied with electricity through a flexible cord. The apparatus
weighs only eighty pounds complete.

Left Home on Freight; Back in Limousine.


To celebrate the anniversary of forty years ago, when he jumped a
freight at the old Delanco, N. J., station and beat his way in a side-
door palace car to a near-by metropolis in search of a chance to
make good, which he thought his home had denied him, a former
Delanco boy came back a day or two ago in a limousine to call on
old friends and renew the friendships of school-days.
The boy was John Cahill, who is now chief counsel of the
American Bell Telephone Company, with offices in New York,
London, and Paris.

Is Given Fullest Penalty.


Judge Maxwell sentenced Merton C. Pierce, of Canton, Pa., to
three months in jail and a fine of $500 and costs of prosecution, for
furnishing liquor to a person of known intemperate habits. Pierce
pleaded guilty to supplying liquor to a man who could not buy for
himself.
“Oh, that the law was more severe in such cases,” said Judge
Maxwell. “I have the utmost contempt for a man who will buy liquor
for a man who is forbidden to buy it himself, and would like to send
you to jail for a longer period, but the law does not allow. However, I
will give you the fullest penalty, and that will keep you behind the
bars for at least six months,” said the judge, in passing sentence.
Another Canton man has been arrested on the same charge, but
will fight the case.

This Cow is Strong for Twins.


James Billingsley, a farmer residing near Axtell, Kan., has a Red
Polled cow that has made a record in raising calves. The animal,
though only eight years old, has given birth to eight calves, four of
which were born within a period of thirteen months. A year ago she
gave birth to twins, and recently she gave birth to a set of twins.
The cow is a fine milker, and all of her calves have brought prices
as high as fifty dollars a head.

Lone Hunter’s Tragic End.


“Have been torn up by a brown bear. No chance to get out. Good-
by.”
Mortally wounded, and with his right arm incapacitated, King
Thurman, a lone hunter and trapper on Chickaloon Flats, Alaska,
crawled to his cabin, printed the above note with his left hand, and
then shot himself with his rifle.
This was the story that was read by the hunters who found
Thurman’s body in his cabin two weeks ago and reported the
tragedy to the authorities at Seward, Alaska.

Twin Brothers Marry Sisters.


Ashland, Pa., had a novel wedding, when Lewis and James
Baglin, twin brothers, were married to Ruth and Ada Maurer, sisters,
by Reverend M. H. Jones.

Refuses to Quit on Pension.


Thomas Strong, of Pine Meadow, Conn., who has been a
trackman on the New York, New Haven & Hartford Railroad for more
than forty years, and is nearly eighty years old, has refused to be
retired on a pension, saying he wants to die in harness. He says he
wouldn’t know what to do with himself if he quit work.

Mustn’t “Cuss” by Wireless.


Radio operators in the United States can’t cuss each other out or
use profanity or indecent language of any kind “in the air.”
A few days ago an operator in the commercial station in
Massachusetts ended up a message with a word that shocked the
inspector in the government station at Boston, where it was picked
up. The department of commerce has sent the offending operator a
strong letter of reprimand, warning him to be careful of his language
in the air in the future or he would lose his license.

Cat’s Cradle Cost One Hundred Dollars.


Louis Newman, of Bayonne, N. J., owns a cat which is the
possessor of a litter of five kittens which Newman values at twenty
dollars a piece, despite their being decidedly common cats, of the
back-fence variety.

You might also like