Arduino Automatic Door: Sliding Door with HC-SR04 or PIR Sensor
How to build an Arduino automatic door: detect people with an HC-SR04 or PIR, open with a servo or stepper, hold time, anti-trap safety and a parts list.
An Arduino automatic door is a door mechanism that opens when a person approaches and closes on its own a few seconds after nobody is left. The Arduino detects the person with either an HC-SR04 ultrasonic distance sensor or a PIR motion sensor, and a servo or stepper motor moves the door. Because it is a small copy of the sliding doors you see in shopping centres, it is one of the most popular builds for school models, science fairs and design and technology classes.
In this guide you will build two versions: a quick hinged or lever door driven by an HC-SR04 and a servo, and a real sliding door driven by a PIR and a 28BYJ-48 stepper motor. You will also find a table of sensor distances and hold times, anti-trap safety (the door reopens if someone steps in while it is closing), a parts list and MicroPython code for the Raspberry Pi Pico. The sketches use millis instead of delay, so the sensors keep being read even while the door is moving.

How does an automatic door work?
Real automatic doors and your model work on the same logic: at any moment the door is in one of four states. In the closed state the sensor is watched; when someone arrives the door switches to opening. Once fully open it waits in the open state and counts a hold time after the person has left. When the time runs out it moves to closing; if the sensor sees someone again during this phase, the door immediately reopens. This structure is called a state machine, and since each state only has to check a couple of rules, the code stays short and reliable. For the details, see the Arduino state machine article.
| State | What happens? | Next state |
|---|---|---|
| Closed | Motor stopped, sensor is read | Person detected: Opening |
| Opening | Motor slowly opens the door | Fully open: Open |
| Open | Door waits, the timer restarts while someone is there | Hold time over: Closing |
| Closing | Motor closes the door, sensor is still watched | Person or obstacle seen: Opening; fully closed: Closed |
Choosing a sensor: HC-SR04 or PIR?
The HC-SR04 sends out an ultrasonic pulse and calculates distance from the time its echo takes to return. Because it reports distance in centimetres, you can write a clear rule such as "open if closer than 40 cm", and it also sees someone standing still. It measures inside a narrow cone (about 15 degrees), so it has to point straight at the area in front of the door. A PIR sensor detects changes in the infrared heat given off by the human body; it covers a wide angle and works from several metres away, but it doesn't report distance and can lose someone who stands perfectly still. For the doorway itself, a separate infrared obstacle sensor makes the door safer. You'll find the details in the HC-SR04 and PIR motion sensor articles, and a comparison in distance sensors compared.
| Sensor | Detection range | Response | Pros | Cons |
|---|---|---|---|---|
| HC-SR04 ultrasonic | 2–400 cm, about a 15° cone | 60 ms per reading | Gives distance, sees a person standing still | Echo gets weak on soft fabric and angled surfaces |
| HC-SR501 PIR | About 3–7 m (set by pot), over 100° wide | 30–60 s warm-up, output time set by pot | Wide area, very cheap, one signal wire | No distance, can miss a motionless person |
| FC-51 infrared obstacle | About 2–30 cm | Almost instant | Ideal for doorway safety | Affected by sunlight and black surfaces |
| RCWL-0516 microwave radar | About 5–7 m | Output stays HIGH for a few seconds | Sees through a plastic enclosure | Very sensitive, may even see through walls |
| Setting | Suggested value for a model | Why? |
|---|---|---|
| Opening distance (HC-SR04) | 25–40 cm (40 in the code) | The area in front of a model door; 80–150 cm on a real door |
| Confirmation readings | 3 in a row (about 180 ms) | A single bad echo shouldn't open the door |
| Hold-open time | 3–5 s (4 s in the code) | Enough to walk through, without waiting needlessly |
| Servo opening speed | 15 ms per degree, 90° in about 1.4 s | Sudden moves strain the mechanism |
| Stepper speed | 1.2 ms per step, 100 mm in about 5.2 s | Faster than this the 28BYJ-48 skips steps |
| PIR time pot | Shortest position (about 3–5 s) | Let the code handle the hold time |
| Reopening while closing | Under 100 ms | The core of anti-trap safety |
Motor and mechanism: servo or stepper?
There are three practical ways to move a model door. The easiest is to fix the door leaf straight onto the shaft of an SG90 servo: as the servo turns from 0 to 90 degrees, the leaf swings open like a hinge. If you want a sliding door, tie a thin wire to the servo horn and build a push rod that slides the door along its track; the stroke is about twice the horn length, so a 25 mm horn moves the door about 50 mm. For a longer, more realistic sliding door, use a 28BYJ-48 stepper motor and a pulley (string or belt); the stroke then depends only on the number of steps. We compare servos and steppers in the DC vs servo vs stepper motor article.
| Mechanism | Motor | Stroke | Note |
|---|---|---|---|
| Hinged leaf | SG90 servo | 0–90° rotation | Easiest build, keep the leaf light |
| Push-rod sliding door | SG90 or MG90S servo | About 2 × horn length (25 mm horn = 50 mm) | Short stroke, for narrow doors |
| Pulley and string sliding door | 28BYJ-48 + ULN2003 | Unlimited; pulley circumference × turns | A closed-position switch is a must |
| Rack and pinion sliding door | 28BYJ-48 or servo | Depends on gear circumference | Very clean with a 3D printer |
Parts list for a school model
- 1 Arduino Uno or Nano and a USB cable
- 1 HC-SR04 ultrasonic sensor or 1 HC-SR501 PIR sensor
- 1 SG90 servo (for a hinged or push-rod door) or 1 28BYJ-48 stepper motor with a ULN2003 driver board
- 1 FC-51 infrared obstacle sensor (for doorway safety) and 1 micro switch (closed position in the stepper version)
- 1 active buzzer, optionally 1 LED and a 220 Ω resistor
- Breadboard, male-to-male and male-to-female jumper wires
- 5 V 2 A adapter or a 4 × AA battery holder (separate supply for the servo and stepper)
- 3–5 mm foam board or plywood for the body, aluminium U channel or straws for the door track, hot glue
Wiring diagram and pin table
| Connection | Arduino Uno (servo version) | Arduino Uno (stepper version) | ESP32 | Raspberry Pi Pico |
|---|---|---|---|---|
| HC-SR04 TRIG | D7 | - | GPIO 5 | GP14 |
| HC-SR04 ECHO | D6 | - | GPIO 18 (via divider) | GP15 (via divider) |
| PIR output (OUT) | - | D2 | GPIO 19 | - |
| Servo signal (orange wire) | D9 | - | GPIO 13 | GP16 |
| ULN2003 IN1 / IN2 / IN3 / IN4 | - | D8 / D9 / D10 / D11 | - | - |
| Closed-position switch (COM → GND) | - | D3 | - | - |
| FC-51 obstacle sensor OUT | D5 | D5 | GPIO 27 | - |
| Buzzer (+) | D8 | - | GPIO 26 | - |
| Sensor VCC | 5V | 5V | 5V (VIN) | VBUS (5 V) |
Step-by-step build
- Cut the model body; leave a doorway at least 8–10 cm wide and make the door leaf as light as you can.
- Mount the door on its track or hinge and slide it by hand before attaching the motor, making sure it never sticks.
- Set the servo to 0 degrees and fit the horn while the door is closed, so that CLOSED_ANGLE in the code matches the closed position.
- Mount the HC-SR04 above or beside the door, facing the area in front of it; make sure it can't see the door leaf.
- Place the FC-51 inside the doorway facing the opposite wall and set its threshold with the onboard pot.
- Wire everything according to the pin table, power the motor from its own supply and join all the grounds.
- Upload the code, open the Serial Monitor at 9600 baud and move your hand towards the sensor to watch the door open and close.
- While the door is closing, put your hand into the doorway; when the door instantly reopens, the safety test has passed.
Arduino code: automatic door with HC-SR04 and a servo
1// Otomatik kapı maketi: HC-SR04 + SG90 servo + IR engel sensörü
2// Automatic door model: HC-SR04 + SG90 servo + IR obstacle sensor
3#include <Servo.h>
4
5const int TRIG_PIN = 7; // HC-SR04 TRIG
6const int ECHO_PIN = 6; // HC-SR04 ECHO
7const int SERVO_PIN = 9; // servo sinyal / servo signal
8const int SAFETY_PIN = 5; // kapı aralığındaki IR sensör, engelde LOW / doorway IR sensor, LOW on obstacle
9const int BUZZER_PIN = 8; // aktif buzzer / active buzzer
10
11const int OPEN_DIST_CM = 40; // bu mesafeden yakınsa kişi var (maket) / closer than this = person (model)
12const int CLOSED_ANGLE = 0; // kapalı servo açısı / closed servo angle
13const int OPEN_ANGLE = 90; // açık servo açısı / open servo angle
14const unsigned long HOLD_MS = 4000; // son algılamadan sonra açık kalma / stay open after last detection
15const unsigned long STEP_MS = 15; // her 1 derece arası süre (hız) / time per 1 degree (speed)
16
17enum DoorState { CLOSED, OPENING, OPEN, CLOSING };
18DoorState state = CLOSED;
19
20Servo door;
21int angle = CLOSED_ANGLE;
22unsigned long lastSeen = 0; // kişinin son görüldüğü an / last time a person was seen
23unsigned long lastStep = 0;
24unsigned long lastPing = 0;
25byte hits = 0; // art arda yakın ölçüm sayısı / consecutive close readings
26
27long readDistanceCm() {
28 digitalWrite(TRIG_PIN, LOW);
29 delayMicroseconds(2);
30 digitalWrite(TRIG_PIN, HIGH);
31 delayMicroseconds(10);
32 digitalWrite(TRIG_PIN, LOW);
33 unsigned long us = pulseIn(ECHO_PIN, HIGH, 25000UL); // 25 ms zaman aşımı ≈ 4 m / 25 ms timeout ≈ 4 m
34 if (us == 0) return 999; // yankı yok / no echo
35 return us / 58; // µs → cm
36}
37
38bool personNear() {
39 long d = readDistanceCm();
40 if (d < OPEN_DIST_CM) { if (hits < 3) hits++; }
41 else hits = 0;
42 return hits >= 3; // 3 ölçüm onayı, gürültü süzgeci / 3-reading confirm, noise filter
43}
44
45void setup() {
46 pinMode(TRIG_PIN, OUTPUT);
47 pinMode(ECHO_PIN, INPUT);
48 pinMode(SAFETY_PIN, INPUT_PULLUP);
49 pinMode(BUZZER_PIN, OUTPUT);
50 door.attach(SERVO_PIN);
51 door.write(CLOSED_ANGLE);
52 Serial.begin(9600);
53}
54
55void loop() {
56 unsigned long now = millis();
57
58 // 60 ms'de bir ölç, yankılar karışmasın / measure every 60 ms so echoes don't mix
59 if (now - lastPing >= 60) {
60 lastPing = now;
61 if (personNear()) lastSeen = now;
62 }
63 bool blocked = digitalRead(SAFETY_PIN) == LOW; // kapı aralığında engel / obstacle in doorway
64 bool someone = (now - lastSeen < 300) || blocked;
65
66 switch (state) {
67 case CLOSED:
68 if (someone) { state = OPENING; tone(BUZZER_PIN, 2000, 80); }
69 break;
70 case OPENING:
71 if (angle >= OPEN_ANGLE) { state = OPEN; lastSeen = now; }
72 break;
73 case OPEN:
74 if (someone) lastSeen = now;
75 else if (now - lastSeen > HOLD_MS) state = CLOSING;
76 break;
77 case CLOSING:
78 if (someone) { state = OPENING; Serial.println(F("Engel! Yeniden aciliyor / Obstacle! Reopening")); }
79 else if (angle <= CLOSED_ANGLE) state = CLOSED;
80 break;
81 }
82
83 // Servoyu derece derece sür, kapanırken her adımda engel kontrol edilir / move one degree at a time
84 if (now - lastStep >= STEP_MS) {
85 lastStep = now;
86 if (state == OPENING && angle < OPEN_ANGLE) door.write(++angle);
87 if (state == CLOSING && angle > CLOSED_ANGLE) door.write(--angle);
88 }
89}| Part | What does it do? |
|---|---|
| OPEN_DIST_CM | A reading closer than this (40 cm) counts as a person |
| personNear() | Needs 3 close readings in a row; a single bad echo won't open the door |
| HOLD_MS | The door stays open for 4 seconds after the person leaves |
| STEP_MS | The servo turns 1 degree every 15 ms; 90° takes about 1.4 seconds |
| CLOSING state | If a person or obstacle is seen while closing, the door reopens at once |
| pulseIn(..., 25000) | Gives up after 25 ms without an echo, so the code never freezes |
Instead of sending the servo to 90 degrees in one go, the code turns it one degree every 15 milliseconds. That has two benefits: the door opens slowly and realistically, and because the sensor is read again on every step while closing, the door changes direction within a few milliseconds when someone steps in front of it. To change the speed, increase or decrease STEP_MS. If the door turns the wrong way, swap the CLOSED_ANGLE and OPEN_ANGLE values. We wait at least 60 ms between readings so that the echo of the previous pulse doesn't spill into the next measurement. We explain why the timing is done with millis in the millis vs delay article.
Stepper-driven sliding door: PIR and 28BYJ-48
For a real sliding-door look, tie the door to a thin string and wind the string onto a pulley on the stepper's shaft. You can find the number of steps you need with this formula: steps = stroke ÷ (π × pulley diameter) × 4096. In half-step mode the 28BYJ-48 takes about 4096 steps per revolution; a 30 mm pulley has a circumference of about 94 mm, so a 100 mm stroke needs 100 ÷ 94.2 × 4096 ≈ 4350 steps. At power-up the code drives the door to the closed-position switch to find its zero point, so even if the power fails with the door half open, the position isn't lost on the next start. Every time the PIR sees movement, the hold time starts again. For more on the motor, see the 28BYJ-48 stepper motor article.

1// Kayar kapı maketi: PIR + 28BYJ-48 step motor (ULN2003) + kapalı konum switch'i + IR güvenlik sensörü
2// Sliding door model: PIR + 28BYJ-48 stepper (ULN2003) + closed-position switch + IR safety sensor
3const int PIR_PIN = 2; // HC-SR501 çıkışı, hareket varken HIGH / output, HIGH on motion
4const int HOME_PIN = 3; // kapalı konum switch'i (COM → GND), basılıyken LOW / closed switch, LOW when pressed
5const int SAFETY_PIN = 5; // IR engel sensörü, engelde LOW / IR obstacle sensor, LOW on obstacle
6const int COIL[4] = {8, 9, 10, 11}; // ULN2003 IN1..IN4
7
8// Yarım adım dizisi: 28BYJ-48'de tur başına ~4096 adım / half-step sequence, ~4096 steps per turn
9const byte SEQ[8] = {0b1000, 0b1100, 0b0100, 0b0110, 0b0010, 0b0011, 0b0001, 0b1001};
10
11const long OPEN_STEPS = 4350; // 30 mm makara, 100 mm strok / 30 mm spool, 100 mm travel
12const unsigned int STEP_US = 1200; // adımlar arası süre, küçülürse adım kaçırır / step interval
13const unsigned long HOLD_MS = 5000; // hareket bittikten sonra açık kalma / stay open after motion ends
14
15long pos = 0; // 0 = kapalı, OPEN_STEPS = açık / 0 = closed
16int phase = 0;
17unsigned long lastStepUs = 0;
18unsigned long lastMotion = 0;
19
20void coilsOff() {
21 for (int i = 0; i < 4; i++) digitalWrite(COIL[i], LOW); // bobinler boşta, ısınmaz / coils off, no heating
22}
23
24void stepOnce(int dir) {
25 phase = (phase + dir + 8) % 8;
26 for (int i = 0; i < 4; i++) digitalWrite(COIL[i], (SEQ[phase] >> (3 - i)) & 1);
27 pos += dir;
28}
29
30void homeDoor() {
31 // Açılışta kapıyı switch'e kadar kapat, sıfır noktasını bul / at power-up close until the switch: find zero
32 long guard = OPEN_STEPS + 500;
33 while (digitalRead(HOME_PIN) == HIGH && guard-- > 0) {
34 stepOnce(-1);
35 delayMicroseconds(STEP_US);
36 }
37 pos = 0;
38 coilsOff();
39}
40
41void setup() {
42 for (int i = 0; i < 4; i++) pinMode(COIL[i], OUTPUT);
43 pinMode(PIR_PIN, INPUT);
44 pinMode(HOME_PIN, INPUT_PULLUP);
45 pinMode(SAFETY_PIN, INPUT_PULLUP);
46 Serial.begin(9600);
47 delay(30000); // PIR ısınma süresi (~30 s) / PIR warm-up (~30 s)
48 homeDoor();
49}
50
51void loop() {
52 unsigned long now = millis();
53 bool motion = digitalRead(PIR_PIN) == HIGH;
54 bool blocked = digitalRead(SAFETY_PIN) == LOW;
55 if (motion || blocked) lastMotion = now;
56
57 long target = (now - lastMotion < HOLD_MS) ? OPEN_STEPS : 0; // açık mı kalmalı? / should it be open?
58 if (blocked) target = OPEN_STEPS; // engel varsa kapanma yok / never close on obstacle
59
60 if (pos == target) { coilsOff(); return; }
61 if (target == 0 && digitalRead(HOME_PIN) == LOW) { pos = 0; coilsOff(); return; } // switch erken geldi / switch reached
62
63 if (micros() - lastStepUs >= STEP_US) {
64 lastStepUs = micros();
65 stepOnce(pos < target ? 1 : -1);
66 }
67}How do you make it safe against trapping?
- Watch while closing: Keep reading the sensor while the door moves. If someone is seen during closing, stopping isn't enough: reopen immediately.
- Doorway sensor: The main sensor only sees the area in front of the door. An FC-51 or a laser and LDR beam placed inside the opening catches someone standing right on the threshold.
- Slow, light door: Keep the closing speed low and the leaf light. A model door too weak to hurt a finger is the best protection anyway.
- Step limit: In the stepper version, if the closed-position switch isn't reached within a set number of steps, the door is stuck; stop the motor and open the door.
- Manual opening: Add a button that opens the door in any state; it also matters that the door can be pushed by hand when the power is off.
MicroPython version with the Raspberry Pi Pico
You can build the same servo door with a Raspberry Pi Pico and MicroPython. Power the HC-SR04 with 5 V from the Pico's VBUS pin and connect ECHO to GP15 through a 1 kΩ and 2 kΩ divider. You can check the values with the voltage divider calculator: 5 V × 2 ÷ 3 ≈ 3.3 V. The servo PWM signal is generated at 50 Hz; a 0.5 ms pulse means 0 degrees and a 2.5 ms pulse means 180 degrees. If you use an ESP32, the Arduino sketch works almost as is; just install the ESP32Servo library instead of Servo and change the pins as shown in the table. If you are new to MicroPython, the MicroPython basics article is a good place to start.
1# Pico otomatik kapı: HC-SR04 (ECHO bölücüyle) + SG90 servo, MicroPython
2# Pico automatic door: HC-SR04 (ECHO through a divider) + SG90 servo, MicroPython
3from machine import Pin, PWM, time_pulse_us
4import time
5
6trig = Pin(14, Pin.OUT)
7echo = Pin(15, Pin.IN) # 5 V ECHO → 1 kΩ / 2 kΩ bölücü → GP15 / divider → GP15
8servo = PWM(Pin(16))
9servo.freq(50) # servo 50 Hz ister / servos expect 50 Hz
10
11OPEN_CM = 40
12HOLD_MS = 4000
13CLOSED, OPEN = 0, 90
14
15def set_angle(a):
16 us = 500 + a * 2000 // 180 # 0° = 0,5 ms, 180° = 2,5 ms
17 servo.duty_u16(us * 65535 // 20000)
18
19def distance_cm():
20 trig.low(); time.sleep_us(2)
21 trig.high(); time.sleep_us(10); trig.low()
22 t = time_pulse_us(echo, 1, 25000)
23 return 999 if t < 0 else t / 58
24
25angle = CLOSED
26last_seen = time.ticks_ms() - HOLD_MS
27set_angle(angle)
28
29while True:
30 if distance_cm() < OPEN_CM:
31 last_seen = time.ticks_ms()
32 target = OPEN if time.ticks_diff(time.ticks_ms(), last_seen) < HOLD_MS else CLOSED
33 if angle != target:
34 # 3 derecelik adımlar, kapanırken de her adımda ölçülür / 3-degree steps, measured on every step
35 angle = min(angle + 3, target) if angle < target else max(angle - 3, target)
36 set_angle(angle)
37 time.sleep_ms(60) # HC-SR04 ölçümleri arasında en az 60 ms / at least 60 ms between pingsProject ideas and upgrades
- Idea: Add a people counter to the door and show how many went in and out on an LCD.
- Idea: For a door that opens only with a registered card, put an RFID RC522 reader in place of, or next to, the sensor.
- Idea: Use the same logic for a barrier that lifts at a car park entrance; the Arduino parking system article is a good base.
- Idea: To also detect someone standing still, try an LD2410 mmWave presence sensor instead of the PIR.
- Idea: Light up the entrance with an LED strip when the door opens at night, and switch it off a few seconds after the door closes.
- Idea: If you're presenting at a fair, prepare a poster and a flowchart with the tips from the science fair presentation article.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| The door opens and closes by itself | The HC-SR04 sees the door leaf or a side wall | Change the sensor angle, lower OPEN_DIST_CM |
| The servo jitters, the Arduino resets | The servo is powered from the Arduino's 5V pin | Use a separate 5 V supply, join grounds, add 470 µF on the supply |
| The stepper hums but doesn't turn | STEP_US too small or IN wires out of order | Raise STEP_US to 1500, check the IN1–IN4 order |
| The PIR opens the door at power-up | The PIR gives random output while warming up | Wait 30–60 s at start-up, the code already does this |
| The door closes late | The PIR time pot is set long | Turn the pot to its shortest position, set the time with HOLD_MS |
| Distance is always 999 on the Pico | Wrong ECHO divider or sensor powered from 3.3 V | Power the sensor from VBUS, measure the divider |
An automatic door brings sensor reading, motor control, timing and safety thinking together in a single project, which makes it a really enjoyable model to learn from. If you want to learn the parts one by one, you can follow the wiring diagrams and code of projects like "HC-SR04 Distance Measurement (Serial Monitor)", "Servo Motor Usage", "Doorbell and Light with a Motion Sensor" and "Stepper Motor Usage" step by step in the BlueGrays app, then combine them all in your own door.
Frequently asked questions
How do you make an automatic door with Arduino?
You place an HC-SR04 distance sensor or a PIR motion sensor in front of the door and move the door with a servo or stepper motor. The Arduino opens the door when someone approaches and closes it after a few seconds once nobody is left. The sensor must keep being read while closing so the door reopens if someone arrives.
Which sensor is used for an automatic door?
For a model, the HC-SR04 is the most practical choice because it gives distance, so you can set the opening threshold in centimetres. A PIR sees a wider area but gives no distance and may miss someone standing still. Real doors combine a microwave radar with an infrared safety sensor in the doorway.
Should I use a servo or a stepper motor for an automatic door?
For a hinged or short-stroke door, an SG90 servo is the easiest solution. For a long, realistic sliding door, a 28BYJ-48 stepper with a pulley is better, because the stroke depends only on the number of steps. If you use a stepper, add a switch so it can find its position.
How long should an automatic door stay open?
For a model, 3–5 seconds is enough; the HOLD_MS value in the code sets this time. The time should be counted from the moment the person was last seen, so the door doesn't close while someone is waiting in front of it. On real doors the time is set according to where the door is used.
What happens if someone steps in while the door is closing?
In good code the sensor keeps being read during closing and the door reopens immediately when someone is seen. The sketches in this article move the servo degree by degree and the stepper step by step, so the change of direction happens within milliseconds. A separate infrared sensor in the doorway makes it even safer.
Why does my servo jitter and reset the Arduino?
When a servo starts moving it briefly draws a high current and pulls down the Arduino's 5V line. Power the servo from a separate 5 V supply, connect the grounds and add a 470 µF capacitor across the supply. Long, thin wires also increase the voltage drop.
Projects to build after reading this
See all projects
HC-SR04 Distance Measurement (Serial Display)
The HC-SR04 sensor works just like a bat finding its way in the dark: it sends out a sound you cannot hear, listens for the echo and measures how far away the object in front of it is.

Using a Servo Motor
The arm of a small servo motor turns to three positions in turn: all the way to the start, right to the middle and all the way to the end, waiting two seconds at each stop.

Motion Detector with Motion Sensor
A simple guard that tells you when someone walks into the room. The motion sensor picks up the warmth given off by the human body, and the Arduino keeps the LED on as long as there is movement and…

Doorbell and Light with Motion Sensor
When someone comes up to your door, you know before they even ring. As soon as the motion sensor spots someone, the LED lights up and the buzzer plays a three-note chime from high to low; when the…

Using a Stepper Motor
A motor that turns step by step, exactly as far as you want, like the hand of a clock.

Automatic Lighting with the ESP32 PIR Motion Sensor
In this project an HC-SR501 PIR motion sensor detects someone entering the room and turns on an LED automatically. millis() tracks how long the LED stays on: each HIGH reading refreshes the last-motion time, and the LED turns off at least 10 seconds after the last HIGH. The code also waits 50 ms with delay(50) in every loop, so the loop is not fully non-blocking. Great for stairs, hallways, bathrooms or closet lighting.

ESP32 RFID Door Lock (RC522 + Servo + OLED + Buzzer + LED)
We build a smart door lock with an ESP32, an RC522 RFID module, an SG90 servo, an SSD1306 OLED display, an active buzzer and 2 LEDs. When a card is scanned, its UID is checked against the authorized cards defined in the code; if it matches, the servo unlocks (green LED + 2 short beeps) and locks again after 5 seconds. An unknown card lights the red LED, gives 3 quick beeps and shows its UID on the OLED.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

