My Interaction Lab Recitation 03

Step 1. 

Step 2. 

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);
//count = tiltVal + 1;
// if the tilt sensor value changed, print the new value
if(tiltVal == HIGH){
count = count + 1;
Serial.println(“Yay, you’ve done one set of curls”);
}
delay(10);
}

 

Step 4.

I noticed that when tilting the device your hand might go over 90 degrees and that’s when it counts it as “HIGH”, whereas if you were to do exactly 90 without giving it much force the device doesn’t feel the difference and the balls inside will be moving so slowly that the program will not detect it. 

 

 

 

Leave a Reply

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