Damped Harmonic Oscillator with Arduino

The benefits of using experiments in physics classes are widely discussed in the literature, but sometimes experimental setups are not available. In this paper we present different ways of using experiments in physics classes based on the Arduino board, since it involves low cost materials and can be built by the own students in several cases. In this work we addressed the well known damped harmonic oscillator and performed the data acquisition through the Arduino board, a LDR (Light Dependent Resistor), a infrared photodiode sensor and a computer. The setup of the proposed experiment and the technical details related to assembly are discussed in a clear way in order to be reproduced by anyone interested in the subject. We found a significant difference in the results obtained through the LDR and the photodiode. The later has given better results and has reproduced a regular decay in the amplitude of the oscillator even when the experiment was performed in a highly illuminated room. The Arduino board, alongside the referred peripherals, has shown great potential for building low cost experimental setups to be used in physics classes, both for expositive and hands on approaches.


Introduction
The use of didactic laboratories in Physics education is widely recommended because it is seen as a fundamental tool for the comprehension of physical phenomena and the underlying theoretical concepts.However, the equipment required for data acquisition is often of high value and their maintenance must be done by specialized technicians, which prevents their wide use in schools or even in colleges.For this reason, experiments based on low-cost materials have become very popular and contribute to improve the qualitative understanding of physical phenomena and to increase the interaction of students with the process of construction of scientific materials.The very act of building these materials carries many benefits, such as: greater understanding of theoretical concepts, practice with trial and error, analysis of the pieces which yield better results and participation of the student as a protagonist in the development of knowledge.
Despite the benefits of making experiments with low-cost materials Ref. [1], the impossibility of obtaining accurate measurements with them makes their use incomplete.In an attempt to fix this lack of accurate measurements, new technologies in Physics education have been implemented in several ways, for example: use of graphics software that allows for the visualization of certain phenomena; use of photosensors and microphones for direct measurements on the computer; development of applets which explore the versatility of changing physical parameters without the risk of breaking an apparatus; and use of electronic microcontrollers to which a large number of sensors can be attached.
All these examples account for a current need of teachers to interact in a more dynamic way with their students and thus make their participation more active.What will influence the choice of a new technology to be used is the relationship between cost, prior knowledge and feasibility of accurate data acquisition.Among these technologies, the most suited to this profile are electronic microcontrollers.The only difficulty in its large-scale use is the need for a prior knowledge of electronics and programming, which many teachers and students do not have.Therefore, the need of such prior knowledge can turn the use of microcontrollers unfeasible and make them accessible to few.The Arduino board was then created in an attempt to increase the large-scale use, by making the implementation of its programs of open access to the public.This community has grown considerably, and a large number of programs and implementations are now available to researchers from various fields, including Physics Ref. [2]- [4].
In this work we show the use of the Arduino platform in a physic experiment: the damped harmonic oscillator.The main focus in this implementation will be discussion between the use of the LDR and photodiode sensors, reporting the accuracy and differences in data acquisition.In Section 2, we briefly discuss about the Arduino platform, showing its versatility.In Section 3 we present the results of the proposed experiments.In Section 4 we present our conclusions and perspectives.The codes of the programs used are available in the Appendices.

The Arduino Microcontroller Platform
The Arduino microcontroller was initially developed around 2005 as a platform for design students in Italy to learn how to develop interactive art exhibits.Arduino is a very popular and easy to use programmable board for creating your own projects.Consisting of a simple hardware platform and a free source code editor, it is designed to be really easy to use without being an expert programmer.The typical Arduino board provides four basic functional elements: An Atmel ATmega328P AVR microcontroller, a simple 5 V power supply, a USB-toserial converter for loading new programs onto the board, I/O headers for connecting sensors, actuators and expansion boards.
Arduino makes several different boards, each with different capabilities.In addition, part of being open source hardware means that others can modify and produce derivatives of Arduino boards that provide even more form factors and functionalities.To mention some Arduino boards: Arduino Uno, LilyPad, Arduino Mega, Arduino Leonardo and Arduino Nano.
The standard way to program an Arduino is via an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment, compiled in the Arduino integrated development environment (IDE).Alternatively, National Instrument's Labview programming environment can use the Arduino as a slave data acquisition device.Further, Arduino boards can communicate with a computer via USB using a virtual serial port.Nearly any programming language is able to communicate through a serial port, and so interfaces in Matlab, Mathematica, Python, and PERL are also available.

Experimental Setup
Harmonic oscillator is largely found in the literature Ref. [5] for being a well-known experiment which is widely used in laboratory classes.
In most cases a sonar captures the movement of the object being analyzed and thus provides the corres-ponding graph.Our experimental setup follows in the footsteps of Ref. [6], in which the experiment is based on a creative and simple assembly, that allow us to reproduce it and then to compare with our results, as can be seen in Figure 1.
The setup consists of a mirror attached to a ruler which in turn is rigidly fixed at one of its ends.The Arduino board in connected to an LDR (Light Dependent Resistor) sensor that captures the light reflected from the mirror which was emitted by a single LED.The ruler will be manually set in motion and since it is fixed at one of its ends, the motion will be strongly damped.We had to modify the original assembly replacing the attached mirror by a white sheet of paper, because the light reflected in the mirror saturated the LDR sensor.
The LDR sensor or photoresistor is a light-controlled variable resistor.The resistance of a photoresistor decreases with increasing incident light intensity which means the resistivity of any photoresistor may vary widely depending on the room light condition.This characteristic makes them unsuitable for applications in an ambient with high luminosity, such as a classroom, when precise measurements are required.The voltage is sent to an analogical gate in Arduino and a simple program reads and stores the data in a file.It is important to mention that we acquire the voltage difference and not the object position as a function of time.
In summary our pipeline consists of gathering the light from the LED (after it has been reflected by the ruler), convert it to a voltage using either the LDR or the photodiode and write both the voltage and the corresponding time to a file using the Arduino board, connected to a computer.One is them able to plot the voltage versus time, that has to decay alike the amplitude of the oscillator.The piece of code used in the data acquisition can be found in the Appendix.

Results and Discussion
The behaviour of the voltage, registered using the LDR, obtained for different room luminosites as a function of time is shown in Figure 2. As we can see, the damped oscillation is not fully observed in high luminosity condition because we cannot see the exponential decay, not even a regular decay, of the characteristic amplitude.The reason behind it is that photoresistors also exhibit a certain degree of latency between exposure to light and the subsequent decrease in resistance, and this lapse of time is crucial in experiments with fast movement.In a luminosity controlled room, with a weak photon emission, a regular decay was observed, as expected (Figure 2-lower panel).This comparison has shown a limitation of the LDR sensor and is one of the features one has to keep in mind during lab activities, specially when a large number of external parameters are involved, in order not to compromise the final result.
In order to obtain a better result in high luminosity rooms, a infrared photodiode was used instead of a LDR.A photodiode is a semiconductor device that converts light into current, which in turn, is generated when photons are absorbed into the photodiode.The benefits of this approach can be seen in Figure 3, in which a clearly regular decay in the registered voltage is observed for different luminosity conditions, in other words independently of light intensity the photodiode behaviour was the same, as expected since it is only sensitive to the IR part of the electromagnetic spectrum.So the benefits of using photodiode instead of LDR sensors in practical applications are evident, but it is also important to note that the difference in the results may be explored to enhance the student's comprehension of the subject.

Concluding Remarks
The Arduino board offers a wide range of possibilities in low cost material experiments for physics teaching.In this work we used a sensor to convert light into voltage and the Arduino board to send the acquired data to a computer.For the particular case of the damped oscillator, the use of a infrared photodiode has given better results, when compared to a LDR, and can be used even in highly illuminated rooms, such as a typical classroom.The decay in the registered voltage depicts the expected decay in amplitude and is consistent with the motion of a damped oscillator.
To summarize and clarify our comparison we can see, in Figure 4, the voltage difference obtained by LDR The experimental setup presented in this work is easy to assemble and can therefore be reproduced in classroom either by teachers or students, making it a good tool for physics teaching.The piece of code needed for the experiment is available in the Appendix providing a straightforward application of the experiment and also leaving room for changes and improvements.Furthermore, this setup is a good solution for Institutions with low budget since the full setup costs $32 and, given the possibilities it provides, is not expensive, specially when compared to commercial experimental setups.
In future projects we will explore advantages of photodiode sensors in more accurate assemblies in order to expand its usability to precise measurements and not only to classroom demonstrations.

Figure 1 .
Figure 1.Photo of the experimental setup (left).A mirror is attached to a ruler, which in turn is rigidly fixed in one of its ends.The Arduino platform is placed below the ruler, where measurements are done by using either LDR or photodiode sensors.Photo the Arduino board used in the assembly (center).Schematic circuit diagram used (right).

Figure 2 .
Figure 2. Plot of damped hamonic oscillator experiment using a LDR sensor in a high luminosity room (upper panel) and in a low luminosity room (lower panel).Solid line in the inset is a guide to the eye for amplitude decay.

Figure 3 .
Figure 3. Plot of damped hamonic oscillator experiment using a photodiode sensor in a high luminosity room (upper panel) and in a low luminosity room (lower panel).Solid line in the inset is a guide to the eye for amplitude decay.

Figure 4 .
Figure 4. Plots of damped harmonic oscillator experiment with difference voltage as function of time using both: LDR sensor and photodiode sensor in different luminosity room.and photodiode sensors in different luminosity conditions where once again the LDR behaviour is acceptable in an low luminosity environment.The experimental setup presented in this work is easy to assemble and can therefore be reproduced in classroom either by teachers or students, making it a good tool for physics teaching.The piece of code needed for the experiment is available in the Appendix providing a straightforward application of the experiment and also leaving room for changes and improvements.Furthermore, this setup is a good solution for Institutions with low budget since the full setup costs $32 and, given the possibilities it provides, is not expensive, specially when compared to commercial experimental setups.In future projects we will explore advantages of photodiode sensors in more accurate assemblies in order to expand its usability to precise measurements and not only to classroom demonstrations.