This morning started with a look at functions, what they are, why we use them and how to construct them in the C programming language.
Today’s project was 12 Knock Lock. In this project we use a piezo to detect sound, as opposed to create sound. To make the piezo a sensitive detector we wired it to ground with a high value (1M ohm) resistor, the Arduino then read the voltage between the piezo and the resistor. We wrote our own function that would analyze the sound detected by the piezo to test whether it fell between an upper and lower detection limit. If it did the function would output True, if not the function would output False.
P.S. Interested to learn more about how piezos can be used to detect sound? Check out this tutorial on building a ‘DIY Contact Mic’ from Collin’s lab.