#3 – Digital I/O (Microphone amplitude sensor)
The two sensors I chose to use were an ordinary SPST switch, and a hybrid digital/analog sensor comprised of a microphone and Arduino code. The microphone sensor simply worked by feeding the input noise into an analog in (first passing through a 100X op amp), and letting the Arduino processor determine if the input noise was “loud” enough (by looking at the amplitude of the signal and seeing if it was above or below a certain threshold voltage away from the midpoint voltage of 2.5V).
In the video below, a regular switch (SPST) is used to rotate through 4 counter states, which control both the binary number displayed on the first two LEDs (iterating through them) and speeding up the third LED. (Note that it checks for the switch too often in this case – if the switch is held down too long, multiple states are gone through at a time. Proper use of a flag/reset architecture would prevent this problem, but I was too lazy to do that for this assignment.)
Then, a microphone hooked up to an op-amp and then fed into the analog input is used to reset the counter state machine whenever a high amplitude noise (such as blowing into the microphone, shown here) is picked up. Clapping provided by Cheng.