You wrote:
The problem with this coding is fsrReading > 10 && fsrReading < 350 , the sensor will keep counting...
What i want is, if the FSR detect range 10 - 350 , the counter just count 1 only... From my code above, the sensor will keep counting when the sensor in the range..
Do you want your counter to increment one time for each time the (FSR) reading goes from outside your range to inside it? In that case, you need a variable (one that keeps its value between calls to loop) to hold the previous state, namely inside vs. outside the signal band of interest. So, I think you may want something like:
#define LOW_THRESH (10)
#define HIGH_THRESH (350)
#define FSR_PIN (whatever)
static boolean prevInRange = false; // persistent variable for previous state
void loop()
{
int fsrVal;
int count = 0;
boolean curInRange;
fsrVal = analogRead(FSR_PIN);
if ((fsrVal >= LOW_THRESH) && (fsr_val <= HIGH_THRESH)) { // is FSR inside defined band?
curInRange = true;
}
if ( (prevInRange == false) && (curInRange == true)) { // then we've just transitioned into the band
count +=1; // increment once per outside-to-inside transition
}
prevInRange = curInRange; // update history for next time
// Your serial output code goes here
}
Hope this helps.