In reception we made a workout sensor using a tilt switch.
In order for the tilt switch to work, the user has to connect it to their forearm. In the diagram above it shows that when the switch senses that its orientation is past 180 degrees it outputs a 1 to the computer. When it returns back to 180 degrees it outputs a one. Because of the changes in number, the computer can then take those and count the number of reps based on the change in number.
To be used correctly this workout tool can be used for a variety of different workouts. If one attaches the tilt switch to their stomach they could count sit ups, if one attached the switch to their calf they could count hamstring curls.
Here is videos of the switch in action:
IMG_6182 <– Jumping jacks
IMG_6179 <– Curls
To begin making this project I took two wires and soldered on to each end of the tilt switch
.
Then I connected the two wires into the bread board along with a resistor and a capacitor.
Next I took the pre written code from the recitation and uploaded it on to my bread board:
int SENSOR_PIN = 2; int tiltVal; void setup() { pinMode(SENSOR_PIN, INPUT); // Set sensor pin as an INP Serial.begin(9600); } void loop() { // read the state of the sensor tiltVal = digitalRead(SENSOR_PIN); Serial.println(tiltVal); delay(10); }
IMG_6173 <– this is a video of the first code working along with the tilt sensor.
Next, I uploaded the second script of code given to us that output a 1 when the tilt sensor went from 0 to 1 and 0 when the tilt sensor went from 1 to 0.
int SENSOR_PIN = 2; int tiltVal; int prevTiltVal; void setup() { pinMode(SENSOR_PIN, INPUT); // Set sensor pin as an INPUT pin Serial.begin(9600); } void loop() { // read the state of the sensor tiltVal = digitalRead(SENSOR_PIN); // if the tilt sensor value changed, print the new value if (tiltVal != prevTiltVal) { Serial.println(tiltVal); prevTiltVal = tiltVal; } delay(10); }
IMG_6176<– Video of uploaded code
The code was almost there but it needed a few finishing touches. I needed to add a condition that only counted a curl only when full curl was completed, create a curl count, and set a limit so when someone reaches that limit they receive a message.
At what angle of tilt does it transition between HIGH and LOW?
The tilt switch transitions between high and low just past 180 degrees on both sides.
What else did you notice about its behavior?
In the beginning I wondered if it was the wires that controlled the tilt switch. Upon further inspection however, I noticed that the wires had nothing to do with it and it was the little cylinder device it self. I Also noticed that when the switch was connected to the arm the number or reps was outtputted a little after 180 degrees which makes sense because to “tilt” something it cannot be directly flat.
What if you rotate the limb that has the sensor attached to it?
When I rotate the limb that the sensor is attached to, usually nothing happens. Its only when I accidentally move the limb up or down while rotating the limb, that the numbers change.
What if you shake it?
If you shake it the tilt switch senses it and believes that a curl was completed. Not only this but it also seems to think multiple curls were completed because it counts up very fast.
What if you hold the wires several centimeters away and tilt it?
If you hold it close to the wire the switch vs. when you hold it further away there is no difference. At first I though that when you held the wires close to the switch it was more sensitive but I realised it was the same angle as when I held it farther way.
Do you think it can be used by any user?
I think that this could be used by a user if there were some adjustments made. I think that as of now, the sensitivity is too finicky in the way that if you shake it, the tilt switch would count the “reps” but if this was revised, than this would be a tool that many gym goers and coaches would love.
Leave a Reply