Recitation 3: Sensors

Step 1: Prepare your tilt sensor

Task #1: Solder

The goal of this task is to prepare the sensor.  For this step, I first tried to wind up the wires with the sensors, and then use the electrical tape to fixate the soldered parts; finally, I use soldering guns to successfully solder them together. 

Task #2:

Connect the tilt sensor cables to your Arduino using a capacitor as the circuit diagram: The circuit is a relatively easy one, so it didn’t take long, but I still ask the LA for help the first time for I misread the part that lead to the sensor and the ground. After correctly understanding that there are two wires connected to the ground, I finished the circuit. 

Task #3: Program

This step only requires copying the code and testing it on our arduino; it went pretty smooth.

Step 2: Refine the code

Task #1:

“Upload the following sketch to only print 1 when the tilt sensor changes from 0 to 1, and 0 when from 1 to 0”. It’s also a simple one and I run the code successfully. 

Step 3: Wear your sensor

“Fix the tilt switch using paper tape to your body, making it a wearable sensor. The sensor should be along your forearm, so that you can use it to detect when your forearm is facing up.” 

For this part, I just taped the sensor I soldered before to my forearm and tried to move it up and down. It worked well and the monitor showed values between 0 to 1. 

 

Step 4: Bicep Curl Workout!

Unfortunately, I accidentally overwrote the code I saved in class, so I only got some videos to prove that I achieved these tasks. 

Task #1: Add a conditional to your sketch so that it shows a message on the Serial Monitor only when a full biceps curl has been completed.

<iframe src=”https://drive.google.com/file/d/1_C8h0n5s2MgpG8kv_UwuksCTC1dqYW6l/preview” width=”640″ height=”480″ allow=”autoplay”></iframe>

Task #2: Count the curls, adding one to its value every time that the user does a complete bicep curl. 

To modify the code, I firstly declared a global variable named “total”, and then I wrote “total == total + 1”, which means adding one to the total every time a full bicep curl is finished.  

Task #3: Set a limit to the variable so that when the total reaches 8, Print “Yay, you’ve done one set of curls”. 

The result is as followed:

 

Leave a Reply

Your email address will not be published. Required fields are marked *