Created
October 26, 2011 01:28
-
-
Save neufuture/1315138 to your computer and use it in GitHub Desktop.
FSR Sensors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int padPins[] = { | |
0}; | |
#define THRESHOLD 20 | |
#define WINDOW 10 | |
#define NUM_PADS 1 | |
struct Pad { | |
bool sampling; | |
int pin, value, peak; | |
}; | |
Pad pads[NUM_PADS]; | |
void setup(){ | |
Serial.begin(115200); | |
} | |
void loop(){ | |
for (int i=0; i<NUM_PADS; i++){ | |
pads[i].value = analogRead(padPins[i]); | |
if(pads[i].value > THRESHOLD && pads[i].sampling){ | |
if (pads[i].value > pads[i].peak){ | |
pads[i].peak = pads[i].value; | |
} | |
else{ | |
Serial.println(pads[i].peak); | |
pads[i].peak = 0; | |
pads[i].sampling = false; | |
} | |
} | |
if(pads[i].value<THRESHOLD){ | |
pads[i].sampling = true; | |
} | |
} | |
delay(10); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment