Recitation 3: Workout Sensors

1.

2. 
int SENSOR_PIN = 2;
int tiltVal;
int counter = 0;

void setup() {
pinMode(SENSOR_PIN, INPUT);
Serial.begin(9600);
}

void loop() {
tiltVal = digitalRead(SENSOR_PIN);
Serial.println(tiltVal);
delay(10);put your setup code here, to run once:
{
if (digitalRead(SENSOR_PIN) == HIGH)
{
for(int counter = 1; counter <= 10; counter = counter +1)
digitalWrite(SENSOR_PIN, HIGH);
delay(250);
digitalWrite(SENSOR_PIN, LOW);
delay(250);
}
else
{
digitalWrite(SENSOR_PIN, LOW);
}
}
}

3.

4. When the arms are fully extended, about 180º wise, it transitions into LOW; when the arms are bent at an about 15º angle, it transitions into HIGH. The sensor is also sensitive to movement, which results in multiple counts from one bicep curl. Additionally, in between counts, the number stays at 1 or 0. If we rotate the limb that has the sensor attached to it, the code does not display it as a rep of the bicep curl, as well as shaking (unless you are bending your elbow). This sensor can be used for any user, not including those who cannot do a bicep curl even without a sensor.

Referring to the pictures above, our group went through a few trial and errors, but were all resolved through collaboration and help through Rudi and a few classmates. Essentially, we had fun throughout the process and were able to experiment with new coding, thus learning new concepts through this interactive recitation.

Leave a Reply

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