Recitation 3: Workout

 

 

For the first task we needed to prepare our tilt sensors. That was interesting, because I love working with the soldering station. It was questionable is the tilt sensor polarized or not, but we all found out that it is not polarized. In addition, we learned that it is much easier to work when you make cables together (like on the photo), I think it will be extremely helpful to know that you can make any shape you like of these wires.

Tilt sensor

Second task was harder for me, because I have never ever worked with this type of diagrams. I used some help from the professors. Now I know what D2 means on this diagrams and what it C 22uF. But I also noticed my improvement of building the circuits. I became faster, and now understand more. I was even  able to help a little bit people around me to build their circuits.

circuit connected

For the task three of the first step we tried to use our Arduinos. Mine worked immediately, so everything was correct.

 In third step me and my recitation partner agreed that it is much easier to just hold the sensor, not to use paper tape. This way it is also easier to do tryouts when working.

Step four was the hardest one. I have not got really much knowledge about Arduino programming language, there were some tasks which we did not study in this course, so my friend helped me a little. I noticed that this language is someway similar to Processing programming language. And I know some basics of it, so it was easier for me to just translate the commands. I understand how the coding is working. But you need to be really careful with punctuation, because one mistake – and your code is broken and you need to debug it. I was able to understand what we need to do, but I didn’t know what is the global variable. Now I know it. Plus, we considered to make the delay bigger for our own comfort and convinience. Device became less sensorable to switching positions, so it was really counting curls when the whole arm is raised.

1st code (we used ‘Great!’ to identify HIGH, and nothing to print LOW, so just the raisings of arm will count) and the second one where we added counting:

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

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

void loop() {
  // read the state of the sensor
  tiltVal = digitalRead(SENSOR_PIN);

  if (tiltVal == 1)
   {Serial.println("Great!");
   
   }
  delay(1000);} 

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

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

void loop() {
  // read the state of the sensor
  tiltVal = digitalRead(SENSOR_PIN);

  if (tiltVal == 1)
   {Serial.println("Great!");
   count++;
   Serial.println(count);
   }
  delay(1000);} 

1st code working:

2nd code working:

3rd code:  (here you can also see how we added ‘tone’ variable to use the buzzer in the 5th task)

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

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

void loop() {
  // read the state of the sensor
  tiltVal = digitalRead(SENSOR_PIN);

  if (tiltVal == 1)
   {Serial.println("Great!");
   count++;
   Serial.println(count);
   }
   if (count==8) {Serial.println ("Yay, you’ve done one set of curls");
   count = 0;
   tone(6, 440);
   }

  delay(1000);
}

3rd code in action:

The lifehack that I was able to remember is to use ‘count ++’ instead of ‘count = count +1’.

Step five was interesting, but we have very limited time to finish it, so we picked just the first idea. One of the possible ways is to change the workout – you can connect sensor to your leg or other part of body to make it counting. We also added buzzer to make our sensor more interactive. 

This sensor can be used in many many ways. I was really exited to see how our own code, circuit, and sensor are working.

 

Scetch of how possibly people can use this device:

Bicep curls counting 

Leave a Reply

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