Recitation 3: Workout

It never occurred to me that a tilt switch can be used to count bicep curls. Although I’m not a fitness fanatic, it’s still really interesting to make this circuit.

It’s so sad that my partner Amber Zhu and I were busy adjusting the circuit and code, so we didn’t put it into actual use. But we still record a video to prove we realized the basic function:

(Also, the number can be counted and a congratulations message would be sent every 8/16/32/…  times.)

And our code is as below:

 int SENSOR_PIN = 2;
int tiltVal;
int prevTiltVal;
int times;

void setup() {
  pinMode(SENSOR_PIN, INPUT); // Set sensor pin as an INPUT pin
  Serial.begin(9600);
  times = 0;
}

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) {
    prevTiltVal = tiltVal; 
    times = times + 1;
  }
  Serial.println(times);
  if (times % 8 == 0) {
    Serial.println("Yay,you've done one set of curls.");
  }
  delay(10);
}

We tried to add a buzzer so that it could sing together with the message, but the time was so limited and we didn’t manage that. What a pity!

I’m not good at drawing but I guess the way of using it can be depicts in this way:

The LOW will switch into HIGH at around 90 degrees. But we found that making the switch move from parallel to vertical could count most precisely, or it couldn’t record every move every time. As we tested with holding the wires several centimeters away and tilting it, I’m pretty sure it can work in this way as long as the switch is greater than 90 degrees.

I think the theory can be applied to develop equipment for any user, but of course the simple version as we did cannot. Also, as it’s not that sensitive, it can better monitor if the user is doing well.

Leave a Reply

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