In today’s recitation, we continued to experiment with Arduino’s functions with this weeks concepts of values and if else statements using servo sensors. My partner and I used the Vibration sensor to play sound from a buzzer, linking the servo motor with an external output.
The circuits were relatively easy to figure out, as to simply connect the motor we followed the Arduino diagram provided in Recitation.
To add the external output, the buzzer, we simply attached the speaker to the breadboard — Here is a photo and a diagram of the final circuit below:
And here is the drawn diagram:
Where we ran into the most trouble was getting the code to work. We thought the circuit wasn’t correct which is why the speaker wouldn’t make any noise despite us knocking the sensor, but it turns out we needed to use ToneMelody in order for the speaker to play the sound. Our first code looked like this:
As you can see, ToneMelody is completely absent from the current code, so we took ToneMelody’s code from Recitation 2 and tried to combine it together like so:
But with this code we saw not only was the ToneMelody code not repeating (so of course the sensor wouldn’t work when pressed) but also we did not input a sensor value for the knock so once over the value would trigger the sound. We saw that the code for Knock, which we got from the Arduino Website, set the sensor value as cont int threshold = 100. So using an if else statement, we set the SensorValue to be >100 so the Knock Sound could be registered. Here is the final code:
Once we had the SensorValue and the If Else Value set up, the Knock Sensor finally worked. Here is a video of the final product:
Documentation Questions:
- We tried to build a Vibration sensor that would trigger a noise whenever it is able to detect movement. This is similar to motion detectors I see at homes: when the alarm is set and once the motion gets close enough to the door an alarm is triggered to sound. I believe people would use this for security: it can be for home protection, or it can be for pets and babies — a sound can play when the pet. or the baby has gone too far or has started to move when they and the house should be asleep.
- The code tells the hardware computer what to do: in order for the Arduino to trigger the analog, physical functions it has to understand what to tell the different parts. That is why despite the fact we got the circuit all correct, none of it could work unless the code was set up in a specific, routine way: code does not allow for deviations which is similar to how a recipe needs to be simple and to the point in order for the product to work.
- I think computers influence almost every aspect, but more specifically I think it has profoundly influence language. This can be seen through text messaging, in which there is a standardized code of abbreviations that people immediately can understand without clarification. I think with computers in terms of interactions we expect a much quicker response — we expect communication not only with our conversational partner but also the computer itself to be instantaneous. Our behavior has become conditioned to reward instantaneous and rapid communication through short hand and social media.