Skip to content

Instantly share code, notes, and snippets.

@neufuture
Created October 26, 2011 01:28
Show Gist options
  • Save neufuture/1315138 to your computer and use it in GitHub Desktop.
Save neufuture/1315138 to your computer and use it in GitHub Desktop.
FSR Sensors
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