/*
Hi, basically I am trying to write an IF/ELSE statement that triggers a light when a pressure sensor is between two values.
In other words, I want the light to respond ONLY if the analog read is between 400 and 600, as opposed to, say, only being above 400.
Here is the code, any suggestions?
*/
int sensor=0;
int threshold=200;
void setup (){
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
Serial.begin(9600);
}
void loop() {
sensor=analogRead(0);
Serial.println(sensor);
if (sensor > threshold) {
digitalWrite(2, HIGH);
}
else {
digitalWrite(2, LOW);
}
}