Though this lab was also wrought with frustrations and technical difficulties, I liked learning and applying different ways in which microcontrollers can respond to input from the physical world. I like imagining how these skills can grow into more complex, artistic projects. I didn’t get to try using the little speaker, but I hope to test sound-related microcontroller functions soon.
I learned that the three main changes in sensor readings that give information about events in the physical world are:
- state change detection (on digital sensors)
- threshold crossing (on analog sensors)
- peak detection (on analog sensors)
I learned that a change of state is measured by storing the previous state of the sensor, for example if the button was off or was on.
I removed the LEDs from the previous lab and typed in the code to count and print the button presses:
I learned that the if statement checks for the state of the button, HIGH meaning pressed, LOW meaning unpressed.
Then I switched the button out for the force sensing resistor (FSR), which required minor changes in wire and resistor positions.
I typed in the code for detecting and printing whether the user interaction was a “tap” a “short press” or a “long press”. Nothing was appearing in the Serial Monitor as I pinched the sensor. Then when I flicked the sensor down I got inundated with “Tap” messages in the Serial Monitor, as you can see in the following video:
I told Pim about this and he suggested changing the resistor. I thought that made sense—maybe the sensitivity was not adjusted to properly “feel” how long a touch to the sensor lasted. I changed the resistor from 220-ohms to 10k ohms. This did not work. I realized I might have switched the button out for the sensor too early, so I switched the button back in. Serial monitor empty. I didn’t figure out my issue, as it was late at night and I decided to try out peak detection.
Peak detection was more satisfying, as you can see in the video below. When I squeezed the sensor strongly the Serial Monitor printed a high number. When I lightly pinched the sensor, the Serial Monitor printed a lower number, though I couldn’t get the number below 50s and I’m curious how one might do that or why it might not be possible.
There was a lot going on in this lab that I would like to review in more detail. I’m still having trouble getting readings, but I’m motivated by the possibilities to which I imagine honing these skills could lead.
Leave a Reply