You are on page 1of 4

An Arduino Investigation of Simple Harmonic Motion

Calin Galeriu, Scott Edwards, and Geoffrey Esper

Citation: The Physics Teacher 52, 157 (2014); doi: 10.1119/1.4865518


View online: http://dx.doi.org/10.1119/1.4865518
View Table of Contents: http://scitation.aip.org/content/aapt/journal/tpt/52/3?ver=pdfcov
Published by the American Association of Physics Teachers

Articles you may be interested in


An Arduino-Controlled Photogate
Phys. Teach. 51, 156 (2013); 10.1119/1.4792011

Empowering Technology and POETRY Supporting Scientific Inquiry: Investigating the Motion of a
Rebounding Trolley
Phys. Teach. 50, 178 (2012); 10.1119/1.3685121

Application of high-speed imaging to determine the dynamics of billiards


Am. J. Phys. 77, 788 (2009); 10.1119/1.3157159

The optical mouse for harmonic oscillator experimentation


Am. J. Phys. 73, 793 (2005); 10.1119/1.1862634

The not-so-simple harmonic oscillator


Am. J. Phys. 65, 1067 (1997); 10.1119/1.18722

This article is copyrighted as indicated in the article. Reuse of AAPT content is subject to the terms at: http://scitation.aip.org/termsconditions. Downloaded to IP:
147.143.2.5 On: Mon, 22 Dec 2014 08:56:45
An Arduino Investigation of Simple
Harmonic Motion
Calin Galeriu, Becker College, Worcester, MA
Scott Edwards and Geoffrey Esper, Bay Path Regional Vocational Technical High School, Charlton, MA

W
e cannot hope for a new generation of scientists spring, a brass weight, and an ultrasonic position sensor, as
and engineers if we don’t let our young students shown in Fig. 1. Pulling the brass weight down a little bit, and
take ownership of their scientific and engineering then releasing it, will start the oscillation. Due to very small
explorations, if we don’t let them enjoy the hands-on cycle of frictional forces, the amplitude of the observed SHM will
design and production, and if we don’t let them implant their slowly decrease in time, but we can neglect this effect when
creativity into a technologically friendly environment. With we analyze just a few cycles.
this educational philosophy in mind, Massimo Banzi1 and We have used springs specially made for the study of
his team have developed and popularized the open source Hooke’s law. One good supplier of such springs is Home Sci-
Arduino microcontroller board. The Arduino board has ence Tools ($1.95, http://www.hometrainingtools.com). We
helped countless people in their science, electronics, robot- have also used a brass weight holder with a base diameter of
ics, or engineering projects, allowing them to build things 4.4 cm and brass slotted weights. The computerized data col-
that we have not even dreamed of. Physics instructors have lection was done with the help of an HC-SR04 ultrasonic dis-
also realized the advantages of using Arduino boards for lab tance sensor ($5.18 from Amazon, http://www.amazon.com),
experiments.2-4 The schools are saving money because the an Arduino Uno microcontroller board ($29.95 from Jameco,
homemade experimental equipment is much cheaper than http://www.jameco.com), a USB cable, and four male-to-
the commercial alternatives. The students are thankful for an female breadboard jumper wires ($0.69 each from Vetco,
educational experience that is more interesting, more loaded http://www.vetco.net). We have also tested a Parallax PING)))
with STEM content, and more fun. As further proof of this ultrasonic distance sensor ($29.95 from Jameco) with similar
new trend in physics education, Vernier5 is now documenting results. We have repeated the SHM experiment with a variety
the use of their probes with Arduino boards. This is why we of springs and masses with excellent results. The data report-
have developed an Arduino-based physics investigation of the ed in this article were obtained with the spring from Home
simple harmonic motion (SHM) of a mass on a spring. The Science Tools using a total mass of 250 grams and using the
experimental data are collected with the help of an ultrasonic HC-SR04 ultrasonic distance sensor.
distance sensor and an Arduino Uno board. The data are The HC-SR04 ultrasonic distance sensor, shown in Fig. 2,
then graphed and analyzed using Origin 9. This rich cross- uses the principle of echolocation. The sensor has four pins:
curricular STEM activity integrates electronics, computer 5 V (power supply), 0 V (ground), trigger pulse input, and
programming, physics, and mathematics in a way that is both echo pulse output. A trigger signal of 5 V, lasting for at least
experimentally exciting and intellectually rewarding. 10 ms, will cause the sensor to emit a short ultrasonic signal.
After the transmission of this short ultrasonic signal, con-
The experimental investigation of SHM sisting of eight pulses at 40 kHz, the sensor will listen for the
The ex- echo. During this time the echo pin is kept at 5 V. After the
perimental receiver detects the echo signal, or after a maximum wait time
setup for our of 38 ms, the echo pin is reset to 0 V. The HC-SR04 ultrasonic
investigation of distance sensor has an operating range of 2 cm to 5 m, with a
SHM consists resolution of 0.3 cm. A datasheet is posted at http://www.elec-
of a stand, a troschematics.com/8902/hc-sr04-datasheet/.
The Arduino Uno is a mi-
crocontroller board based on
the Atmega328 microcontroller
integrated circuit. It draws cur-
rent from a USB cable, or from
an ac-to-dc adapter. It has six
analog input pins and 14 digital
input/output pins. Detailed
hardware documentation, the
free Arduino software (the in-
Fig. 1. The experimental setup for our investi- Fig. 2. The HC-SR04 ultrasonic distance sensor. tegrated development environ-
gation of SHM. Our students Colin Wolfe and
Nathan Youngs have helped us with the data ment), and plenty of program-
collection and analysis.
DOI: 10.1119/1.4865518 The Physics Teacher ◆ Vol. 52, March 2014 157
This article is copyrighted as indicated in the article. Reuse of AAPT content is subject to the terms at: http://scitation.aip.org/termsconditions. Downloaded to IP:
147.143.2.5 On: Mon, 22 Dec 2014 08:56:45
Fig. 4. SHM data analysis done using Origin 9.

example code for how to use the PING))) sensor. This code is
called from the Examples|Sensors menu. A tutorial about the
PING))) sensor is also posted on the official Arduino site at
http://www.arduino.cc/en/Tutorial/Ping. The Arduino code
that we have used is a variation of this PING))) example code.
The Arduino board is measuring the echo time with the
help of the pulseIn() function, which in this case measures
Fig. 3. The Arduino code used for data collec- the total time (in ms) during which the HC-SR04 sensor keeps
tion. the Echo pin at 5 V. By multiplying this time with the speed of
ming examples are provided on the official Arduino website at sound in air at room temperature (343 m/s), we obtain the to-
http://arduino.cc. tal distance d traveled by the ultrasonic pulse. When the HC-
The HC-SR04 sensor is connected to the Arduino Uno SR04 sensor is centered very precisely under the brass weight,
board with the help of four male-to-female breadboard this total distance is the sum of two sides in an isosceles tri-
jumper wires. The Arduino Uno board supplies the voltage to angle. The height in this triangle is the distance to the brass
the HC-SR04 sensor. The Vcc pin of the sensor is connected weight, the position x that we are looking for. The distance
to the 5 V pin of the Arduino board, and the GND pin of the between the transmitter and the receiver of the HC-SR04 sen-
sensor is connected to a GND pin of the Arduino board. The sor is 2.6 cm, and we can use the Pythagorean theorem to cal-
Trig pin of the sensor is connected to the Arduino digital pin culate the distance x. This correction becomes very important
7, and the Echo pin of the sensor is connected to the Arduino when the distance between the sensor and the brass weight
digital pin 8. is small, just a few cm. With this correction accurate results
A short piece of Arduino programming code, shown in can be obtained even with shorter stands. Our code improves
Fig. 3, is needed to collect the experimental data. The com- the PING))) example code in three ways. Our code works for
puter first compiles this program and then sends it to the Ar- both 3 and 4 pin sensors, we implement a Pythagorean cor-
duino board through the USB cable. The Arduino board will rection in the calculation of the distance, and we use floating
execute the code and will repeatedly send back to the com- point arithmetic in the calculation and reporting of the data.
puter the two experimental measurements, the internal clock
time, and the distance to the brass weight. The measurements Data analysis
are repeated every 10 ms. The list of experimental measure- Data analysis was done using an evaluation copy of Ori-
ments is copied from the Arduino Serial Monitor window and gin 9 downloaded from http://www.originlab.com. Origin
pasted into a Microsoft Excel worksheet. is a powerful software application specifically tailored for
If the PING))) sensor is used instead, then the trigPin and scientific calculations. We have used the Nonlinear Curve
echoPin constants have to be set to the same number, 7, since Fit option, with a User Defined fitting function of the form
this sensor uses only one pin for both the trigger and the echo A*sin(2*pi*x/T+B)+M. For our example the amplitude A is
signals. In this case the SIG pin of the PING))) sensor is con- 7.3460.026 cm, the period T is 0.767540.00018 s, the ini-
nected to the Arduino digital pin 7. tial phase B is 3.5730.014 rad, and the midline (equilibrium
The Parallax PING))) sensor has been on the market for position) M is 43.5460.015 cm. The R2 value is very close to
about 10 years. During this time this sensor has become very one, a further indication that the sinusoidal model describes
popular, and fortunately the Arduino software comes with an very well the experimental data. The value of the period can

158 The Physics Teacher ◆ Vol. 52, March 2014


This article is copyrighted as indicated in the article. Reuse of AAPT content is subject to the terms at: http://scitation.aip.org/termsconditions. Downloaded to IP:
147.143.2.5 On: Mon, 22 Dec 2014 08:56:45
5. “A guide to using Vernier sensors with Arduino,” The Caliper
30, 1-2 (Fall 2013).

Calin Galeriu is teaching physics at Becker College and math at Bay


Path Regional Vocational Technical High School. He earned a BS degree in
physics from the University of Bucharest, MA degree from Clark University,
and a PhD degree from Worcester Polytechnic Institute.
Becker College, 61 Sever St., Worcester, MA 01609;
Calin.Galeriu@becker.edu

Scott Edwards is an electronics instructor and vocational lead teacher


at Bay Path Reg. Voc. Tec. High School. He has a BS in engineering from
UConn.
Bay Path Reg. Voc. Tec. High School, 57 Old Muggett Hill Rd.,
Charlton, MA 01507; SEdwards@baypath.net

Geoffrey Esper is an electronics instructor at Bay Path Reg. Voc. Tec. High
School. He has a BS and MA degree in physics from Clark University.
Fig. 5. Experimental investigation of Hooke’s law. Bay Path Reg. Voc. Tec. High School, 57 Old Muggett Hill Rd.,
Charlton, MA 01507; GEsper@baypath.net
be used to calculate the elastic constant of the spring:
k = m(2.p/T)2 < 16.75 N/m.
The same experimental setup can be used to investigate
Hooke’s law. This will produce an independent measurement
of the elastic constant of the spring. We have used total mass-
es from 100 g to 450 g. The graph of the applied force mg as a
function of position x displays the anticipated linear behavior,
and the slope of the line of best fit gives the elastic constant.
ement Par k Physic
A mus
The value obtained this way, k <16.77 N/m, is very close to
the value determined from the period of the SHM. Another s
important observation is that the spring has a residual force,
and it won’t stretch if the mass of the brass weight is less than
100 g.

Conclusions 2nd Edition


We have developed an Arduino-based exploration of the by Clarence Bakken

simple harmonic motion of a mass on a spring. By using an


Arduino Uno board and an HC-SR04 ultrasonic distance
sensor, this very important physics experiment can be per-
formed on a budget, with an excellent match between the
experimental data and the theoretical model. This integrated
STEM activity has also uncovered some fundamental connec-
tions between physics, electronics, computer programming,
and mathematics. This Arduino-based investigation of SHM
has helped the students to improve both their experimental
and theoretical skills. We would like to thank the anonymous
referee for very valuable comments. Plan now for your spring trip to
the local amusement park
References
1. Massimo Banzi, Getting Started with Arduino, 2nd ed. (O’Reilly And save $5 through March 31!
Media, 2011).
Completely updated, Amusement Park
2. K. Zachariadou, K. Yiasemides, and N. Trougkakos, “A low-
Physics, 2nd ed. gives teachers a gamut of
cost computer-controlled Arduino-based educational labora-
subjects ranging from ways to incorporate
tory system for teaching the fundamentals of photovoltaic
amusement parks in classroom work to
cells,” Eur. J. Phys. 33, 1599–1610 (Nov. 2012).
practical suggestions for taking a class to
3. Eric Ayars, “Applications of Arduino Microcontrollers in Un- Physics Day.
dergraduate Laboratories,” invited talk presented at the AAPT
national meeting in New Orleans, LA, Jan. 2013.
4. Calin Galeriu, “An Arduino-controlled photogate,” Phys. Teach.
www.aapt.org/Store
51, 156–158 (March 2013).

The Physics Teacher ◆ Vol. 52, March 2014 159


This article is copyrighted as indicated in the article. Reuse of AAPT content is subject to the terms at: http://scitation.aip.org/termsconditions. Downloaded to IP:
147.143.2.5 On: Mon, 22 Dec 2014 08:56:45

You might also like