Recitation3: Workout

  1. Step 4

(biceps curl)

Step5

(triceps curl)

  1.  
int SENSOR_PIN = 2;
int tiltVal;
int prevTiltVal;
int count;
void setup() {
pinMode(SENSOR_PIN, INPUT); // Set sensor pin as an INPUT pin
Serial.begin(9600);
Serial.println(“Start your WORKOUT!!!”);
}
void loop() {
// read the state of the sensor
tiltVal = digitalRead(SENSOR_PIN);
// if the tilt sensor value changed, print the new value
if(prevTiltVal == 0 & tiltVal == 1){
count +=1;
Serial.println(count);
}
if(count == 8){
Serial.println(“Yay, you have done one set of curls”);
count = 0;
}
if(tiltVal != prevTiltVal){
// Serial.println(tiltVal);
prevTiltVal = tiltVal;
}
delay(10);
}

 

3.

 

4.   I have a further understanding of the device after I’ve tried more tests.

I’ve learned that if tilted at 90 degrees or greater than 90 degrees, it would transitions between HIGH and LOW.

When I rotated the limb that had the sensor attached to it, the tilt sensor worked and printed 1 and 0.

When I shook it, the tilt sensor worked and printed 1 and 0. But proper strength is required, since the sensor failed to print the numbers when I slightly shook it.

When I held the wires several centimeters away and tilted it, the sensor worked and print the numbers easily.

2 thoughts on “Recitation3: Workout

Leave a Reply

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