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!
Codes:
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);
}
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.
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);
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.