1. ro
  2. en
07 August 2025

Photon Unlocker

How I Turned a Sci-Fi Movie Idea into a Real Light-Based Unlocking System

 

Imagine being able to open a secret door using nothing but your phone’s flashlight. No keys. No passwords. Just light.

 

From Fiction to Functionality

 

I watched a Netflix movie that stuck with me — Brick, a sci-fi thriller where the residents of an apartment building are cut off from the outside world by a mysterious, seemingly indestructible wall. After many failed attempts, they discover the wall responds to an electromagnetic code transmitted as light pulses. They use a phone flashlight, send a precise sequence of signals, and... the wall gives way. I thought it was brilliant — not just as a cinematic idea, but as a technical concept. And I asked myself: what if I could turn that fiction into reality?

 

That’s how Photon Unlocker was born — a system that doesn’t rely on buttons, cards, or wireless connections. Just light. I used an LDR sensor (a photoresistor) and an Arduino UNO board, and transmitted the signal using my phone’s flashlight, encoded in Morse code. If the sensor is well hidden, no one would suspect that access is granted by a flashlight. It’s like a secret code, visible only to those who know what to look for.

 

The Concept: Communication Through Light

 

 

At its core, my project is based on optical communication — an old principle, but incredibly versatile. Using Morse code transmitted via a phone flashlight and an LDR sensor, I built a system that can decode light signals and respond to a predefined message.

 

It’s a locking and unlocking mechanism that doesn’t use buttons, cards, or wireless protocols. Just light. And not just any flashlight — the signals must have a specific duration and sequence, controlled by a mobile app.

 

For testing, I used a simple but fascinating app — Morse Code Torch — which converts text into light signals. The Arduino reads analog values from the photoresistor and determines whether the flashlight is on or off. Based on the signal duration, it decides whether it’s a dot or a dash, builds the message character by character, and compares it to a preset password. If the message is correct, it turns on an LED. After 10 seconds, the LED turns off and the system returns to listening mode — just like safes or electromagnetic locks, to avoid wasting energy or leaving doors unlocked.

 

What I loved most was turning a movie idea into a real, functional system. Morse code, though old, is incredibly robust. The photoresistor, typically used to measure ambient light, becomes a signal receiver. And Arduino provides the flexibility and timing precision needed to interpret the message. It’s a clear example of how imagination and technology can work together to create ingenious solutions.

 

Photon Unlocker can be used in discreet access systems — safes, doors, cabinets — or in escape room-style games. It can serve as a contactless remote control, or simply as an educational experiment that teaches how optical communication works.

 

 

 

 

Circuit Diagram

 

The circuit is extremely simple: the photoresistor is connected to analog pin A0, along with a 10kΩ resistor forming a voltage divider. The LED is connected to digital pin D13.

 

I tested codes like “1234”, “ABCD”, and even “SOS”. The system responded flawlessly, lighting up the LED only when the correct message was received.

 

The source code is available on this page, which means you can customize the unlocking code however you like.

 

As you may notice, the circuit relies on a few simple but effective connections between components:

 

  • Terminal 1 of the photoresistor (LDR) → connected to 5V on the Arduino

  • Terminal 2 of the photoresistor (LDR) → connected to analog pin A0 and to terminal 1 of resistor R1 (10kΩ)

  • Terminal 2 of resistor R1 (10kΩ) → connected to GND on the Arduino

 

For the LED setup:

  • Terminal 1 of resistor R2 (220Ω) → connected to digital pin D8 on the Arduino

  • Terminal 2 of resistor R2 (220Ω) → connected to the anode (+) of the LED

  • Cathode (-) of the LED → connected to GND

 

Bill of Materials:

 

  • Arduino Uno or any compatible microcontroller board

  • LED — to indicate successful unlock

  • Resistor R2 – 220Ω (red-red-brown-gold) — current limiter for the LED

  • Resistor R1 – 10kΩ (brown-black-orange-gold) — for the voltage divider with the LDR

  • LDR (Light Dependent Resistor) — used to detect light signals

  • Breadboard — for prototyping the circuit

  • Jumper wires — for connecting components

 

 

 

🛠️ Installing Components on the Breadboard

 

 

As you’ll notice, the number of electrical connections required is quite manageable. You just need to pay attention to a few key details to ensure everything is set up correctly:

  • LEDs are polarized components, meaning they must be connected in the correct direction. To help guide you, we’ve labeled the legs as A (anode, +) and K (cathode, −). If installed backwards, the LEDs won’t light up.

 

 

  • Resistors are non-polarized, so they can be placed in either direction. Their role is to limit current and protect sensitive components, especially the LEDs.

  • If this is your first time using an Arduino board, you can connect everything without worry. A fresh board won’t have any preloaded programs, so there’s no risk of unexpected behavior during setup.

 

 

 

Source Code

 

Install the Morse Code Torch App

Before uploading the source code to your Arduino board, make sure to install the Morse Code Torch app on your smartphone.

  • Open the Google Play Store

  • Search for: “Morse Code Torch”

  • Select the app developed by perryOnCrack

  • Install it on your device

This app will allow you to convert text into light pulses using your phone’s flashlight — a key element in transmitting the unlock code to the system.

 

 

Configure the Morse Code Torch App

Open the Morse Code Torch app, as we need to adjust a key setting to synchronize the light signal emitted by your phone’s flashlight with the data received by the Arduino.

  • Locate the parameter called Unit Duration

  • Set its value to 110 milliseconds — this ensures the timing of dots and dashes matches what the Arduino expects

  • In the text box labeled “abcd”, enter the code you want to transmit

  • To begin sending the light signal, tap the Play button (the triangle icon)

 

 

 

 

You can download the source code here.

 

Note: The link opens a .ino file in a new browser tab. Since most browsers treat it as plain text, you’ll need to save it properly:

  • Press Ctrl + S

  • In the “Save as type” dropdown, choose “All files”

  • Add the .ino extension to the filename (e.g., PhotonUnlocker.ino).  Alternatively, you can copy the entire code (Ctrl + A, then Ctrl + C), open a new sketch in the Arduino IDE, and paste it (Ctrl + V) directly.

 

Once you've assembled all the components on the breadboard, download the source code from the link above and upload it to your Arduino board. With everything in place, you're ready to enjoy your new project — Photon Unlocker in action!

 

 

Testing the System

 

Once the circuit is powered, open the Morse Code Torch app on your smartphone. If you haven’t already done so in the previous step, set the Unit Duration parameter to 110 milliseconds.

 

Type the message “abcd” into the text box as previously indicated. Point your phone’s flashlight toward the photoresistor at a distance of about 10–20 cm, then press the Play button (the triangle or arrow next to the text box) and wait for the light signal to be transmitted.

 

If everything is working correctly, the LED should turn on for 10 seconds, then turn off automatically, waiting for a new light-coded sequence to reactivate.

 

At this point, you can customize your system by changing the password. To do so, locate the following line in the source code:

if (decodedMessage.endsWith("ABCD") && !ledIsOn) {

 

Replace the message "ABCD" with your own password sequence. Note: You must keep the quotation marks, and the message should be written using uppercase letters or digits, as appropriate.

 

 

 

If your project isn’t working properly:

  • there might be too much ambient light in the room, causing the sensor to misread the signal. In this case, adjust the sensitivity threshold

 

const int threshold = 150; // Light threshold for detection

 

How to Test and Set the Correct Sensitivity Threshold

 

  • Run this program on your Arduino.

  • Open the Serial Monitor in the Arduino IDE (shortcut: Ctrl + Shift + M).

  • Turn your phone’s flashlight on and off, placing it where you intend to use it with your device.

  • You’ll see the LDR (Light Dependent Resistor) values change in real time — typically ranging from 0 to 1023:

    • High values = strong light

    • Low values = darkness

  • Record the minimum and maximum values you observe, then calculate the average between them. This average will serve as your sensitivity threshold.

    🔍 Example: If the maximum value in ambient light is 300, and the minimum value when the flashlight hits the sensor is 45, then:  (300−45)/2=127.5(300 - 45) / 2 = 127.5 In this case, a threshold of 150 was chosen, since 127 felt too low.

 

  • If you believe the light sensitivity threshold is set correctly but the program still isn’t working, you can slightly adjust the Unit Duration parameter in the Morse Code Torch app to 100 ms or 120 ms for better timing.

 

  • If the system still doesn’t respond correctly, double-check your electrical connections to ensure everything is wired properly.

 

What We've Learned

 

  • Morse code is an incredibly robust method of communication, even in modern applications.

  • The LDR (Light Dependent Resistor) isn’t just for measuring light—it can also be used to interpret signals.

  • Arduino provides flexibility and precision when it comes to timing and signal processing.

  • Inspiration can come from the most unexpected places — even from a movie.

 

Photon Unlocker is more than just a project. It’s a powerful demonstration of how imagination and technology can work together to create ingenious solutions.

 

 

 

​​​​​​​

​​​​​​​