DEV Community

張旭豐
張旭豐

Posted on

I Made a Mask That Knows When You're Close

I Made a Mask That Knows When You're Close


開發ログ #1

I made a mask.

When you get close to me, the lights on it change. Not because you pressed anything. Not because you touched it. Just because you're there.

This is what it looks like:

Humanphobia — Interactive LED Mask

It has five states:

  • Idle — waiting
  • Random — lights flicker unpredictably
  • In order — lights sweep in sequence
  • Strobe — rapid blinking
  • All lights on — maximum brightness

The pattern depends on how far away you are.

The whole thing runs on an Arduino Nano, 90 blue LEDs, an ultrasonic sensor, and a 9V battery. Here's the circuit:

Humanphobia Circuit Diagram


What I Used

  • Arduino Nano
  • HC-SR04 ultrasonic sensor (the "eyes" — it measures distance)
  • 90 blue LEDs (arranged in a matrix)
  • 9V battery
  • A mask frame to hold everything

That's it. No soldering required for the prototype — I used a breadboard-compatible setup.

The key component is the ultrasonic sensor. It emits a sound wave, measures how long it takes to bounce back. The closer you are, the faster the return. Arduino reads this as a number — smaller = closer.


The Code

The code uses the NewPing library to handle the ultrasonic sensor cleanly.

#include <NewPing.h>

#define TRIG_PIN 12
#define ECHO_PIN 13
#define LED_ARRAY_PIN 9

NewPing sonar(TRIG_PIN, ECHO_PIN, 200); // max distance: 200cm

void setup() {
  pinMode(LED_ARRAY_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int distance = sonar.ping_cm();

  if (distance == 0) {
    // Nothing detected — idle
    idle();
  } else if (distance < 10) {
    allOn();
  } else if (distance < 30) {
    inOrder();
  } else if (distance < 60) {
    randomMode();
  } else {
    strobe();
  }
}
Enter fullscreen mode Exit fullscreen mode

The logic is straightforward:

  • Far away → strobe (you see it from across the room)
  • Getting closer → random flicker
  • Very close → sequential sweep
  • Right in front → all lights on

The Moment That Makes It Worth It

Here's the thing.

Most LED projects are like a flashlight. You turn them on and they stay on. You turn them off and they stay off. There's no sense of the thing being aware of anything.

This mask is different.

It does nothing until you're close enough. Then it reacts. The reaction isn't dramatic — it's just a change in the light pattern. But the fact that it happened because you were there changes the entire feeling.

This is the moment I was trying to capture.

Not "a mask that blinks." A mask that knows you're close.


How This Connects to Bigger Work

There's a project on Behance called The Dots — seven hexagonal panels coated in polarizing film. Each panel rotates as you approach. The closer you get, the more transparent they become. The farther you step back, the darker they become.

The creator describes it as "Magic of Lights." Viewers call it "mesmerising."

The principle is exactly the same as the mask. Sensor reads distance. Distance controls response. You don't press anything. You don't do anything. The space just knows you're there.

That "it knows you're there" quality — that's what separates interactive art from electronics projects.


What Would You Make?

The mask is one version. But the principle scales.

You could make:

  • A panel on your wall that glows warmer as you approach
  • A sculpture that rotates faster the closer you get
  • A sound installation that changes pitch based on how many people are in the room
  • An inflatable wall that puffs up when someone walks by (this is what Bubble Wall does)

All of them work on the same chain:

Proximity → Reading → Response

You don't need to understand electronics deeply to start. You need to understand what you want the viewer to feel.

Ask yourself:

  1. What do I want them to feel when they're far away?
  2. What do I want them to feel when they're close?
  3. How should the transition between those two states feel?

If you can answer those three questions, you can build anything.


Next Time

Next, I'm thinking about adding a second ultrasonic sensor on the back of the mask. So it can react differently depending on which side you approach from — front, back, or side.

I'm also experimenting with LED patterns that feel more organic. Instead of the five fixed patterns, I want something that breathes — slowly brightening and dimming, the way a sleeping animal might.

That "breathing" quality is harder to engineer than a simple on/off. But that's the next challenge.

What would you try?


Parts Used

Part Approximate Cost
Arduino Nano $5-8
HC-SR04 Ultrasonic Sensor $3-5
90x Blue LEDs + Resistors $3-5
9V Battery $2
Mask frame / housing varies

Total: ~$15-20 for the basic version.


Project Reference: Humanphobia by youjin-c

Top comments (0)