Recitation3: Sensor

1.Record a short video of yourself doing step 4 (bicep curls) and 5 (challenge) while showing the Serial monitor/plotter in action.  

IMG_0119 IMG_0118

2. Embed your code into your blog as shown with the example codes in this recitation, NOT by taking a screenshot of it.

int SENSOR_PIN = 2;
int tiltVal;
int prevTiltVal;
int times = 0;
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 (tiltVal != prevTiltVal) {
    Serial.println(times);
    times = times + 1;
    //count the times you exercise
  }
  prevTiltVal = tiltVal;
  delay(10);
  if (times == 8){
    Serial.println(“Yay, you’ve done one set of curls”);
    times =1;
    //reset the times
  }
}
 

3. Draw your own illustration sketches that showcase how a person would use this interactive training device.

4. Reflect on your experiments, explaining the notes you took, and adding photos, and/or screen shots to document what tests you have tried and what you have learned from them. As a guidance, use the following questions:

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

When the sensor is perpendicular to the ground, it’s recognized as high; when it’s parallel to the ground, it’s recognized as low.

What else did you notice about its behavior?

When I move it horizontally, nothing will happen.

Do you think it can be used by any user?

Of course yes. It can’t recognize the user, and no matter who uses the device correctly, it will interact with the user.

Leave a Reply

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