http://www.cs.appstate.edu/ret The Research Experience for Teachers Program Velocity and the Speed of Sound Introduction/Motivation: Two of the most important concepts covered in High School Physics are speed and velocity. Both of these concepts can be demonstrated using real-life scenarios, from a moving car to a whizzing bullet. Another way to demonstrate these concepts is to use the Speed of Sound. The goal of this activity is to not only demonstrate and learn about the concepts of speed, but also to test and measure the Speed of Sound for ourselves. This lab will teach us more about general physics, and writing a program to solve a problem. Materials List/Prerequisites: Complete the “Setting Up the littleBits Arduino” lab activity Three Micro-USB to USB adapters Two littleBits w6 Arduino Leonardo Module littleBits p3 USB Power Module littleBits p3 Power Module At least 2 littleBits o6 Buzzer Modules At least 3 littleBits LED light Modules (o14 Bright LED or o3 RGB LED recommended littleBits i20 Sound Trigger littleBits i13 Light Sensor littleBits w19 Split or littleBits w7 Fork littleBits i3 Button Module The PC, Linux Machine, or Mac Desktop on which the software required for the “Setting Up the littleBits Arduino” lab activity was installed Procedure: Background/Preparation: You should understand the basics of coding in ISO C++ for the Arduino, so you can write your own code to estimate the speed of sound, as well as some knowledge about each of the littleBits pieces mentioned above. You should also have a basic knowledge of sound (how it travels, how fast, etc.) Activity: This lab activity is designed as a team activity, as the lab can neatly be divided into two halves, based on the two Arduinos. These two Arduinos are shown below, and the role of each can be inferred by analyzing the figures. (Figure 1 – 3) Figure 1: Initial Configuration Figure 2: Sensing light causes timer to be turned on Figure 3: Sensing sound causes timer to go off Figure 1 displays the initial configuration where a button, buzzer and LED are connected to the Arduino on the left and the light sensor and sound trigger are connected to the Arduino on the right. The code utilizes a timer that is initially off. In Figure 2, the press of the button has caused the buzzer to emit sound and the LED to emit light simultaneously. When the light sensor in the right Arduino detects the light, the timer is turned on. The light is indicated by the yellow line and the sound is indicated by the light brown line. Figure 3 shows that when the sound reaches the sound trigger the timer is turned off. Team Member 1 – Emitting Arduino: The first team member will be responsible for two challenges. They will have to assemble the emitting Arduino, which is the Arduino unit that will emit light and sound on command. This team member must also design a data table for this lab. Assembling the Arduino: There are a few requirements for assembling the emitting Arduino. Because we want the Arduino to emit based on the push of a button, we must have the battery pack connected to the button, and the button connected to the Arduino on the INPUT side. On the OUTPUT half of the Arduino, we must connect Buzzer(s) and LED(s). It does not matter how they are connected as long as we can turn them on at the same time. Code: The flowchart in Figure 4 demonstrates the purpose of the emitter code. There are many ways to achieve this specific goal, however, all methods will use a variable for the state of the button. Figure 4: Emitter Code Data Table: After your Arduino has been assembled and programmed, you will likely have extra time while your teammate works on their Arduino. Use this time to begin the assembly of a data table! Trial # Distance Time 1 Time 2 Time 3 Average Time Expected Time % Error 1 .350 m **** **** **** **** 1020 µs *** 2 3 Fill in a few distances that represent the distance between buzzer and the sound trigger/ (You are going to experiment with these distances after your teammate implements the Receiving Arduino so choose realizable values for the distance.) Fill in the Expected Time based upon the speed of sound. You’ll fill in the rest of the table after the Receiving Arduino portion of the lab is complete. For those who do not know, % error, or Percent Error, is calculated by the ( |Expected Value – Calculated Value| / Expected Value) * 100. This tells you how much you are off from the actual value. A % error of less than 10% is considered a success for this lab. Team Member 2 – Receiving Arduino: This team member must make an Arduino unit that can time the difference between the light receiver and the sound trigger – thereby getting a measurement for the Speed of Sound. Assembling the Arduino: While the code is challenging for this Arduino, assembly is actually very simple. This Arduino must provide USB Power to a “w19 Split” which will then carry the power to the Sound Trigger and the Light Sensor. Those two sensors will be connected to the Arduino, which must be connected to the computer, so that Serial communication is possible. The Code: The goal of this code it to start a microsecond timer when the light sensor receives a signal, and stop the timer when the Sound trigger is pinged. There are several pieces of code that need to be implemented for this code to work including the “Threshold,” and the timer. This code can be tricky to write, so the following instructions are more detailed. Threshold: The “threshold” is a value that the light sensor must exceed to be counted as “ON.” What we don’t want our code to detect is that the LED is on when actually the sensor is detecting ambient light. Thus, we will take an average of the ambient light in the room to be our threshold. However, if the average is our threshold, then some of the ambient light values may exceed that threshold. The light sensor values range from 0 to 1023. To account for values that can be greater the average, we’ll calculate a threshold that is 100 more than the calculated average. The flow chart in Figure 5 illustrates how to calculate the threshold. This code should be placed in the void setup() function since it only needs to be performed once. 10000 trials may seem like a lot, but the computer can calculate this in milliseconds. Figure 5: Calculating the threshold Timer: Once we have an accurate threshold, we need to create a variable that acts as a timer. This is not excessively complicated, it is simply another while loop that counts up our variable as time passes. The flowchart for the timer code can be seen in Figure 6. Figure 6: Calculating the Speed of Sound You may have noticed that instead of printing the Timer value, we’re printing the Timer value – 2150. This is due to how the sound trigger works. The sound trigger takes a short time to convert the sound waves it is receiving to electricity that can be processed by the Arduino, it takes about 2150 microseconds. In most situations, 2150 microseconds is completely negligible, but when we try to calculate the speed of sound at distances less than .3 meters, this 2150 microseconds causes our timer value to almost triple what we are expecting. However, because the time it takes for the sound trigger to convert the sound waves into a quantifiable value is nearly constant, all we must do is subtract 2150 from the time we determined. (You may find in your experiments that 2150 isn’t the correct value for your particular set up, in which case you’ll need to adjust your code to use the correct value.) Now you’re probably asking “Won’t the length of our code mess up our timer value, because processing the code will take some time that won’t be included in our timer value?” This is a perfectly valid question. However, the speed of the Arduino answers this question for us. It takes the Arduino about a nanosecond to process our code. That means that every time we increase the timer value by 1 microsecond, we are off the actual time value by 1 nanosecond. This means that whenever the timer value reads 1000 microseconds, we are actually closer to 1001 microseconds. That difference is completely negligible, it makes very little difference for our purposes. So don’t worry about it! The input and output devices (light sensor, buzzer, LED, sound trigger) are slow and it is that slowness that is accounted for by the adjustment of 2150. But, the Arduino processor is very, very fast. Recording Data Values: Because we are measuring our time values in microseconds, we can use short distances to calculate an accurate measurement of the speed of sound. I recommend using distances of less than .350 meters, otherwise the sound and light sensors might not trigger correctly. This will cause your % error to be extremely high, which something we don’t want. Results: Now we have many distances to work with, and many different times associated with those distances. The next step is to graph a distance vs. time line chart. When graphed, it is easy to see a constant slope in the graph, and you can even calculate the line of best fit to highlight this slope. When you calculate this line of best fit, you may see that the y-intercept for this chart is about 0, but the more important information comes from the slope of this graph. The slope of this graph has a value of about 340 meters/second. This is the exact value for the speed of sound, and it has the exact units of the speed of sound. Therefore we can conclude that if we graph distance (y) vs. time(x), the slope of the graph is the speed. This is an important conclusion. Conclusion: The main goal of this lab was not to determine the speed of sound, but to learn that slope of a distance (y) vs. time (x) graph will always be the velocity. This is incredibly important physics concept, as it is used in many labs and problem sets. It also sets the foundation for the entire rest of the physics class. However, many other useful things are taught in the lab too. To complete many of the coding challenges, you have to think like a computer scientist, and to understand and solve many of the potential errors that occur with the lab, you have to think like an engineer. This new method of thinking will be vastly important for troubleshooting any future labs you may do. Troubleshooting: If you are having trouble writing the code, I encourage you to make notes on what you are attempting to do within the code. Sometimes simply thinking about your ultimate purpose will reveal an easier or cleaner path. Also, remember to open the Serial communication. That is an easy thing to forget, and it will create an error. If you are receiving strange values or errors, I would double check the sensor’s code, to make sure it is working properly. Then I would take lots of trials to see if it was a random error or a constant problem. If it is a constant problem, I suggest trying to simplify your code, and then moving to a quieter and darker room. Remember that lots of ambient light can make it difficult for the light sensor to function properly. Extra Work (if you finish early): If you finish early, you may want to see if you can improve your code. It is always possible to shorten the length and running time of your code. If you are looking for more engineering challenges, try to see what happens when you increase the distance to beyond .40 meters (Hint: It has to do with the lag on the Sound Trigger) Resources: These resources should help with any coding problems you may be having. http://discuss.littlebits.cc/t/introduction-to-arduino-programming-1-the-basics/22237 http://discuss.littlebits.cc/t/introduction-to-arduino-programming-2-push-my-button/22238 http://discuss.littlebits.cc/t/introduction-to-arduino-programming-4-blinkys-revenge/22240 These next resources are useful dictionaries if you are looking for functions for the Arduino. https://www.arduino.cc/en/Reference/HomePage https://www.arduino.cc/en/Reference/Serial https://www.arduino.cc/en/Reference/DelayMicroseconds
© Copyright 2026 Paperzz