Documentation for Recitation 3: Workout

Recitation 3: Workout

Today we made a bicep curl workout detector using Arduino. Also, we used codes to make Arduino count bicep curls. Here is my result.

To begin with, we used a code to test if the sensor is working.

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);
}

Then, we refined the code as follows to make sure every bicep curl we did could be primarily counted.

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);
} 

After that, I taped the sensor onto my front arm to make it wearable. To make Arduino count more precisely, we modified the code into this:

int SENSOR_PIN = 2;
int tiltVal;
int prevTiltVal;
int count=0;


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 == HIGH && tiltVal != prevTiltVal) {
    prevTiltVal = tiltVal; 
    count=count+1;
    Serial.println(count);
  if (count==8){
    Serial.println("Yay, you’ve done one set of curls");
    count=0;
  }
  

  }
   prevTiltVal = tiltVal; 
  delay(10);
}

Now, the Arduino bicep curls counter was finally complete. I think people can use this counter to work out as this sketch shows:

Questions

  • At what angle of tilt does it transition between HIGH and LOW?

After observation, I think the voltage transition when my front arm is approximately parallel to the ground.

  • What else did you notice about its behavior?

The sensor is over-sensitive sometimes and makes the Arduino overcount. 

  • What if you rotate the limb that has the sensor attached to it?

Arduino will count one bicep curl.

  • What if you shake it?

Still, Arduino will count one bicep curl.

  • What if you hold the wires several centimeters away and tilt it?

Arduino will count as usual.

  • Do you think it can be used by any user?

On one hand, it is useable in that it has complete circuits and coding. On the other hand, it is unnecessary when we do bicep curls because we can count on our own. Moreover, it restricts our movement and the location where we can do bicep curls. And it sometimes will overcount if the move is not proper.

Leave a Reply

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