Hi, I am currently working on a project in witch I want to fire a laser at multiple LDRs (one at a time) to change the brightness of LEDs, I currently have my circuit working but need help adding an extra feature:
As it stands I shine a laser at my chosen LDR and an LED lights up with its set brightness, and extra LED also lights up, this can be ignored. I want to have it so that when I shine the laser at a specific LDR for 3 seconds, it locks that choice into place until I shine it at another LDR for 3 seconds. hope that makes sense, thanks in advance !!!
Here is the code so far:
const int LDR0 = A0;
const int LDR1 = A1;
const int LDR2 = A2;
const int LED = 9;
const int LED1 = 2;
const int threshold = 960;
void setup() {
pinMode(LED, OUTPUT);
pinMode(LED1, OUTPUT);
Serial.begin(9600);
}
void loop() {
int LDR0_val = analogRead(LDR0);
delay (50);
int LDR1_val = analogRead(LDR1);
delay(50);
if (LDR0_val > threshold) {
analogWrite(LED, 10);
digitalWrite(LED1, HIGH);
}
else if (LDR1_val > threshold) {
analogWrite(LED, 150);
}
else {
digitalWrite(LED,LOW);
digitalWrite(LED1,LOW);
}
Serial.println(LDR0);
delay(50);
}