instructions: https://wp.nyu.edu/shanghai-ima-interaction-lab/recitation-3-workout/
soldering the tilt switch to long cables
build the circuit
I first mistook the circuit diagram. I thought the tilt switch and the capacitor were not connected.
The output looked like this:
And this is the circuit after I fixed the problem.
Videos shows the output changes according to the rotation of tilt switch.
Step 4 task1’s video:
Step 4 task2’s video:
Step4 task3’s video:
Step5
I add a potentiometer to my circuit and I can set the repetitions a round requires. I add a new global variable and its value is set according to the slide potentiometer when the code starts.
video:
Step5’s Code:
int SENSOR_PIN = 2; int tiltVal; int prevTiltVal; int count = 0; int read,maxvalue = 16; void setup() { pinMode(SENSOR_PIN, INPUT); // Set sensor pin as an INPUT pin pinMode(A0, INPUT); Serial.begin(9600); count = 0; read = analogRead(A0); read = map(read,0,1023,4,maxvalue); Serial.println(read); } 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(tiltVal); prevTiltVal = tiltVal; if(tiltVal==1){ count++; Serial.println(count); if(count==read){ Serial.println("Yay, you've done one set of curls"); count=0; } } } delay(10); }
Sketches:
before working out, the users will set the potentiometer to decide how many repetitions in a round. The circuit will respond and start the counter.
Reflections:
At what angle of tilt does it transition between HIGH and LOW?
The tilt switch will transition when its angle is close to horizontal.
What else did you notice about its behavior?
There is a click sound when the tilt changes.
What if you rotate the limb that has the sensor attached to it?
The couter will increase if you lift and put down your limb. But the counter will keep the same if you just rotate your wrist.
What if you shake it?
Because of the inertia, the counter will count randomly when you shake the tilt. The faster you shake the tilt, the more likely counter remains the same.
What if you hold the wires several centimeters away and tilt it?
It will change correctly.
Do you think it can be used by any user?
I don’t think so. Because I didn’t write enough instructions. Also, users have to download an Arduino IDLE in their computer.
Leave a Reply