Opening a door with Arduino and push button

Arduino UNO 01-04-25
19 0

Tutorial plan

1- How Open a door with Arduino and push button ?

2- Required Components

3- Circuit Connections of system

4- Arduino program to control the door

 

 

How Open a door with Arduino and push button ?

This project involves creating an automatic door opening system using an Arduino, a push button, a servo motor, and an LCD I2C display. The push button acts as a trigger to open or close the door, while the servo motor controls the door’s movement. The LCD display provides user feedback by showing messages like "Door Open" and "Door Closed".

1- System Initialization

- When powered on, the Arduino initializes the LCD display and servo motor.

- The LCD displays the message: "Door closed".

- The servo motor is set to 85° (door closed position).

2- Button Press Detection

- The Arduino monitors the push button for a press event.

- When the button is pressed, the Arduino triggers the servo motor to rotate 20° to open the door.

- The LCD updates the message to "Door Opened".

- The system waits for the next button press.

3- Auto Closing the Door

- When the button is pressed again, the servo motor returns to 85° (closing the door).

- The LCD updates to "Door Closed".

- The system waits for the next button press.

 

Required Components

Arduino UNO

Arduino Uno 

The Arduino UNO acts as the main controller of the system. It processes the push button input, controls the servo motor, and updates the LCD display.

Push Button

A simple momentary push button is used to trigger the servo motor to open or close the door. When pressed, it sends a signal to the Arduino.

Servo Motor (SG90 or MG995)

The servo motor is used to rotate the door open or closed. It moves to a specific angle controlled by the Arduino.

Function in the System:

Rotates 20° to open the door.

Rotates back to 85° to close the door.

LCD I2C Display (16x2 or 20x4)

Pinouts of 1602 LCD display with I2C

The LCD display provides real-time status updates about the door (e.g., "Door Open", "Door Closed").

10kΩ Resistor (Pull-Down Resistor)

Résistance

A 10kΩ resistor is used to stabilize the push button input.

Breadboard

Breadboard

- Provides a convenient wiring interface.

- Connects components like the servo motor, LCD screen, and Micro:bit GPIO extension.

- Allows power distribution (5V, GND) to different components.

Wires and Jumpers

Fils de connexion

Ensure proper routing of power, ground, and data signals.

Wooden house prototype

- Represents a real-life house model with a door that opens and closes.

- The servo motor is mounted inside the house, controlling the door movement.

- The LCD screen is attached to the exterior for status display.

- The Micro:bit and electronics are placed inside, acting as the control system.

Circuit Connections of system

 

Connection of LCD I2C display to Arduino

LCD I2C Display Pin

Arduino Pin

GND

GND

VCC

5V

SDA

A4

SCL

A5

Connection of servo motor to Arduino

Servo motor

Arduino UNO

Brown wire (-)

GND

Red wire (+)

5V

Yellow wire (Signal)

D2

Connection of push button to Arduino

Push button

Arduino UNO

a leg

D3

another leg

GND (via 10kΩ resistor)

 

Arduino program to control the door

This code uses the LiquidCrystal_I2C library for the LCD display.

1- Open Arduino IDE.

2- Go to Sketch → Include Library → Manage Libraries.

3- Search for LiquidCrystal_I2C and install it

 

How the Arduino code works ?

1- Setup Phase:

- The LCD is initialized with a welcome message.

- The servo is positioned at 85° (closed door position).

- The button is set as an input with a pull-up resistor.

2- Loop Execution:

- The Arduino checks if the button is pressed.

- If pressed, the door opens (20° rotation), and the LCD updates.

- If pressed a second time, the door closes automatically (returns to 85°).

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info