Beginner here needing some help

I have this issue where my Force sensitive resistor(FSR) is causing my Temperature sensor(LM35) to spike up when i apply pressure to the FSR. I don't think this should be happening as they both are not connected together.

Also how do I make it so where a timer/counter starts when the FSR hits the threshold and after more than 1 minute, it activates a Alarm and a LED?
Help is much appreciated!


int fsrAnalogPin = 3; // FSR is connected to analog 3
int LEDpin = 11; // connect Red LED to pin 11 (PWM pin)
int fsrReading; // the analog reading from the FSR resistor divider
float temp;
float startTime;
const int threshold = 800;//an arbitrary threshold level that's in the range of the analog input

void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
pinMode(LEDpin, OUTPUT);

void loop(void) {

fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");

if(fsrReading > threshold){
startTime = millis();

if(fsrReading > threshold && startTime >= 5000){

temp = analogRead(A1);
temp = temp*0.48828125;


Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

You need to detect when the force becomes above the threshold rather than when it is above the threshold

See the StateChangeDetection example in the IDE

You should first rule out hardware issues. Use decoupling capacitors and make sure you don't have ground loops. Use a single-point ground or a beefy (i.e. very low-resistance) ground bus.

shouldn't this be A3 (/hardware/arduino/avr/variants/standard/pins_arduino.h)

why not simply (startTime doesn't serve any purpose)

    digitalWrite (LEDpin, fsrReading > threshold);

Whilst it is more explicit to use A3 as the pin number, which I would encourage, the compiler is smart enough to use the correct pin with analogRead(3);


#define PIN_A3   (17)

There is an excellent tutorial here on how to use millis:

Using millis for timing

if(fsrReading > threshold && startTime >= 5000){

The way you have it startTime will be more than 5000 if it is made equal to millis more than 5 seconds after power is applied to your Arduino. Study the tutorial to see how to use millis correctly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.