Quick recap:
Now we are tasked to combine the AnalogInOutSerial sketch with some kind of analog input. For our Drunk Walking Situation, Mallika and I have decided to explore the detection of pacing associated with inebriation."Left foot, right foot...lerf toot,,rghithoorshf... ..."
We have two Force Pressure Sensors (FPI) for measuring footsteps. Each FPI has a range of pressure sense for 0–100 lbs of pressure. The harder the footstep, the more force detected, and, by our setup, the more its corresponding LED lights up. The code takes analog inputs from A0 (Left foot) and A1 (Right foot), and produces output to the variable pins 10 and 9._A LEFT footstep lights up GREEN. _A RIGHT footstep lights up YELLOW.
Pressing on the right foot initiates the yellow LED light. |
How We Intend to Use this Data:
- PACING can be computed as a function of the inputs over time
- BALANCE can be derived through comparisons between the two inputs' pressure resistances
Action shots
Testing it with a sensor inside a sock. (Heel location works best.) Testing it with pacing: |
The code:
/*
AUTHORS: sarah churng; mallika simone
SUMMARY: Measures the force exerted in walking.
Reads in analog input via Force Pressure Sensors (FPS) from
pins A0 and A1, maps the results to 2 respective ranges from 0
to 255, and uses the result to set the pulsewidth modulation
of the output pins 9 and 10.
CIRCUITS:
1* FPS connected to analog pin A0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 10 to ground
2* FPS connected to analog pin A1.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground
USE AND POTENTIAL for the data collected:
* PACING: as a function of the inputs over time
* BALANCE: as a comparison between the two inputs' pressure resistances
*/
// ANALOG DATA: Left Foot
const int analogInPin1 = A0; // Force Pressure Sensor at A0
const int analogOutPin1 = 10; // LED at variable pin 10
int sensorValue1 = 0; // value from variable sensor
int outputValue1 = 0; // value from output to analog out
// ANALOG DATA: Right Foot
const int analogInPin2 = A1; // Force Pressure Sensor at A1
const int analogOutPin2 = 9; // LED at variable pin 9
int sensorValue2 = 0; // value from variable sensor
int outputValue2 = 0; // value from output to analog out
// INITIALIZE serial communications at 9600 bps
void setup(){
Serial.begin(9600);
}
void loop(){
// READ: analog values
sensorValue1 = analogRead(analogInPin1); // Read in input from left foot
outputValue1 = map(sensorValue1, 0, 1023, 0, 255); // map to range of analog 0 - 255
analogWrite(analogOutPin1, outputValue1); // change the analog out value
sensorValue2 = analogRead(analogInPin2); // Read in input from right foot
outputValue2 = map(sensorValue2, 0, 1023, 0, 255); // map to range of analog 0 - 255
analogWrite(analogOutPin2, outputValue2); // change the analog out value
// PRINT: outputs to serial monitor
if ( sensorValue1 = 0 ){ // If left foot is resting,
Serial.print("Left Foot = 0" ); // print 0 values
Serial.println("\t\t\t\tLeft force = 0");
}
if ( sensorValue2 = 0 ){ // If right foot is resting,
Serial.print("\t\tRight Foot = 0" ); // print 0 values
Serial.println("\t\t\t\tRight force = 0");
}
else{
Serial.print("Left Foot = " ); // When exerts pressure,
Serial.print(sensorValue1); // print left pressure and analog out
Serial.print("\t\t\t\tLeft force = ");
Serial.println(outputValue1);
Serial.print("\t\tRight Foot = " ); // When right foot exerts pressure,
Serial.print(sensorValue2); // print right pressure and analog out
Serial.print("\t\t\t\tRight force = ");
Serial.println(outputValue2);
}
// WAIT
delay(500); // Wait half a second for next loop.
}
This is some AWESOME testing!! I love the idea of checking the imbalancedness of the person as a proxy for drunkenness. You might try creating a "percentage imbalanced" variable which equals the difference, or the quotient of the two feet's forces. that way, you could tell from one number whether the person was drunk or not. also, what other factors might be useful in singling out drunk users?
ReplyDelete