Arduino Photoresistor + LED Escape Room

by iKritixal in Circuits > Arduino

443 Views, 0 Favorites, 0 Comments

Arduino Photoresistor + LED Escape Room

ArduinoEditEscape.png

The following escape room takes an inside look into the Fountain of Youth and this is the setup for an Arduino puzzle. The setup requires a photoresistor and a LED.

Supplies

1 Arduino Uno

1 USB

1 LED

1 Breadboard

4 Jumper Cables

1 Photoresistor

2 Resistors

Step 1 - Setting Up the Code

For this escape room, you will need the included code in Arduino.

This will tell the Arduino to measure the input of light to result in the LED to flash.

// C++ code

// int reading = 0;

int counter;

void setup() { pinMode(A0, INPUT); Serial.begin(9600);

pinMode(3, OUTPUT); }

void loop()

{ for (counter = 0; counter < 10000; ++counter)

{ reading = analogRead(A0); Serial.println(reading);

if (reading < 450)

{ digitalWrite(3, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(3, LOW);

delay(100); // Wait for 100 millisecond(s)

} else

{ digitalWrite(3, LOW);

}

}

}

Step 2 - Setting Up the Hardware

Copy of 2.10 Photoresistor with LED blinking.png

This step requires multiple steps to establish the proper connection.

- Insert any color LED to points D19 and D20.

- Insert a photoresistor to points D25 and D26.

- Place one resistor at points B19 and on negative line.

- Place other resistor at points B25 and on negative line.

- Connect wire GND to negative line.

- Connect wire 5V to B26

- Connect wire A0 to C25

- Connect wire 3 to B20

Step 3 - Playing the Escape Room

The puzzle must now begin the simulation sequence to start the escape room. For this to work the coding must be less than 400 kiloohms.