Hello,
I have managed to get everything to work for my project. When Pressure sensor is being pressed my LED flashes which is what I want it to do, though with my light sensor I can't get it to turn off when light is on it and i don't know how to make it on when it is dark and off when its light
Here is my code
// constants won't change
const int ANALOG_THRESHOLD = 340;
// constants that will change
int light_sensor = A2;
int light_sensor_Value;
int ledPin = 10;
int fsrPin = A3; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(light_sensor, INPUT);
pinMode(fsrPin, INPUT);
}
void loop() {
//light_sensor_Value = analogRead(light_sensor); // read the input on analog pin2
//Serial.println(light_sensor_Value); // print out the value you read
fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading); // print the raw analog reading
if (light_sensor_Value > 120) {
digitalWrite(ledPin, LOW);
}
else if (fsrReading > ANALOG_THRESHOLD){
digitalWrite(ledPin, HIGH);
delay (100);
digitalWrite(ledPin, LOW);
delay (100) ;
}
else {
digitalWrite(ledPin, HIGH);
}
delay(100); // delay in between reads for stability
}