Robot Doorman
Completed: September 2025
Description:
When I moved into my first apartment, they gave me four different keys to unlock various doors just to enter my unit. As it grew colder in Boston, I found it extremely inconvenient to come home after a long day of work and stand outside the apartment building fumbling for my keys just to enter the building and get warm. So instead, I built a robot arm which detects when I buzz my own unit and automatically lets me in.
This has been an absolute game changer, especially when I'm carrying groceries, and has always been a great conversation starter when people come visit!
Code
#include <ESP32Servo.h>
#define PIEZO_PIN A0
#define SERVO_PIN D1
Servo servo;
int buttonOffAngle = 0;
int buttonOnAngle = 90;
int buzzThreshold = 800;
int buzzTime = 3000;
int buzzTimeError = 1000;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(PIEZO_PIN, INPUT);
servo.attach(SERVO_PIN);
servo.write(buttonOffAngle);
}
int reading;
bool waiting;
unsigned long lastTime;
unsigned long currentTime;
void loop() {
// put your main code here, to run repeatedly:
reading = analogRead(PIEZO_PIN);
Serial.println(reading);
if ((reading > buzzThreshold) && (!waiting)) {
waiting = true;
lastTime = millis();
}
else if ((reading > buzzThreshold) && (waiting)) {
}
delay(500);
servo.write(buttonOnAngle);
delay(2000);
servo.write(buttonOffAngle);
delay(3000);
}