Hello,
My wife and I are trying to design a Barbie-themed escape room for Halloween. We have a puzzle planned, where there are 4 blank Ken portraits, and you have to follow a logic puzzle to place the correct prop on each one. This will trigger an LCD to display the 4 digits necessary to get into a lock.
Because we already use magnets on the portraits, and magnets in the props (like pin the tail on the donkey) we can't use magnet sensors to trigger the correct sequence, so we're trying to use LDR sensors instead. That way, once all 4 props are placed in the correct spots, the LDR sensors will be covered up, and the LCD will display the code.
We're prototyping our idea now, and so far we've figured out how to get one LDR to light up one LED once the light is at the correct value.
The problem we're having is getting 3 more LDR's programmed into the code. Then getting the trigger to occur once the value of all 4 LDR's is at a certain number to trigger the LCD display.
Here is the code we have running for 1 LDR to 1 LED. It's working exactly fine, but we're stuck when trying to get our second LDR to work.
int ldrPin = A0; // LDR pin
int ldrVal = 0; // Value of LDR
int ledPin = 2; // Build in LED pin
void setup() {
Serial.begin(9600); // Initialise the serial monitor
pinMode(2, OUTPUT);
}
void loop() {
ldrVal = analogRead(ldrPin); // Read the analog value of the LDR
Serial.println(ldrVal); // Show the value in the serial monitor
if (ldrVal < 700) { // If the LDR value is lower than 700
digitalWrite(ledPin, HIGH); // Turn buildin LED on
} else {
digitalWrite(ledPin, LOW); // Turn buildin LED off
}
delay(100); // Pause 100ms
}
What I'm imagining is a statement that says something akin to "if all ldrVal <700" digitalWrite LED on".
Hopefully, that makes sense. My wife and I are brand spanking new to this whole Arduino game. We're currently working our way through the Elegoo kit, but so much of this code stuff is still greek to me haha.
Thanks for reading this dissertation of a post! Any help is greatly appreciated!
-Brad