Project Summary:
This is my first project with Arduino board (technically speaking, RedBoard). I decided to to make a circuit that receives stimuli from external forces and hence makes something happen.
After playing around with different components in my toolkit, I decided to use the pressure sensor (FSR) as the core of the project. 
The inspiration behind this idea comes from the pain resulted from a pinch. As you squeeze the sensor harder, a buzzer will buzz at a higher pitch and an LED with blink at a faster rate.
First try:
So the plan is:
Based on some reading materials and a few basic tutorials I had done, I designed the first circuit.
The schematic looks like this:
However, there are major problems in the design, as back that time I did not have a solid understanding of how to send the information gathered by the sensor to the board.
Unsurprisingly, the circuit did not work and went kind of crazy. It did respond to my pinch to a certain extend, but not in the desired way.

The first try to build the circuit. 

Fun fact: I needed a 10k-ohm resistor but did not have any at hand, so I adjusted a potentiometer to a 10k position and used it as a temporary resistor.

Second Try:​​​​​​​
After consolidating my understanding of the potentiometer mechanism in the class and consulting my instructor, I made a redesign of the circuit.
Although my instructor had made sure that I made the physical circuit correctly, it still behaved weirdly. After spending sometime debugging the codes, I finally made it work in the desired way. 
Also, I found a cool thing about it is that if I add a noticeable delay between the buzz sound bits, it will sound like an impromptu 8-bit music.
Lessons learnt from this project:
1. Serial.print() issue: During my second try, at some point, all the code seemed fine but the physical circuit wouldn’t work. I kept getting gibberish when I tried to print the value of the sensor reading to the console. Later I figured out that it was because of the way I printed values. If I include both a string and the variable in one print function, the numerical value gets messed up. 
2. Power/no power: At the beginning I was confused about whether a component should be connected to the power pin or not. This is what Ive learnt:
if a component generates analog output, it should be powered by a power pin on the board, while being connected to an analog inout pin. 
However, if a component involves digital signals, then it only needs to be connected to a digital pin and no power pin connection is required.
Also, the digital pins with the PWM~ symbol can provide analog voltage output.
3. Build upon a basic example: A trick my instructor has told me: when starting to write codes for a project, rather than starting from scratch, it might be easier to pull out a relevant example from the built-in library and built on top of the existing codes.
4. Different update frequencies: A trick I figured out by myself. When running both the buzz() and the led() function in the loop() function, the two components’ states get updated at the same rate, which is not what it want (I want the buzzer to have a longer delay between tones to make it sound like an 8-bit tune, and the LED to refresh quick enough to make smooth transitions between different brightnesses). So I used a for loop and a modulo operator to unsync the update frequency of them.
Back to Top