Arduino UNO Bluetooth-Controlled Smart Locker with Servo Motor
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a servo motor using an Arduino UNO, an HC-05 Bluetooth module, and various other components. The circuit includes a 24/12V buck converter to step down the voltage, a 5V relay for switching, and an IR sensor for distance measurement. The Arduino UNO is programmed to control the servo motor based on Bluetooth commands and distance measurements.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
HC-05 Bluetooth Module
- Description: Bluetooth module for wireless communication.
- Pins: Key, VCC, GND, TXD, RXD, State
Servo
- Description: Servo motor for precise control of angular position.
- Pins: GND, VCC, PWM
5A Fuse
- Description: Fuse to protect the circuit from overcurrent.
- Pins: 1, 2
24/12V Buck Converter
- Description: Buck converter to step down voltage from 24V to 12V.
- Pins: VIN+, VIN-, 5V, GND
IR Sensor
- Description: Infrared sensor for distance measurement.
- Pins: out, gnd, vcc
MKE-M08 LCD2004 I2C Module
- Description: LCD display module with I2C interface.
- Pins: GND, 5V, SDA, SCL
5V Relay
- Description: Relay module for switching high power devices.
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
2.1mm Barrel Jack with Terminal Block
- Description: Power connector for external power supply.
- Pins: POS, NEG
DIP Switch 1 Position
- Description: Single position DIP switch for manual control.
- Pins: 1, 2
12V 5Ah Battery
- Description: Battery for powering the circuit.
- Pins: 12v +, 12v -
Electrolytic Capacitor
- Description: Capacitor for filtering and smoothing voltage.
- Pins: -, +
- Properties: Capacitance: 0 Farads
Resistor
- Description: Resistor for current limiting.
- Pins: pin1, pin2
- Properties: Resistance: 2000 Ohms
Resistor
- Description: Resistor for current limiting.
- Pins: pin1, pin2
- Properties: Resistance: 1000 Ohms
Wiring Details
Arduino UNO
- GND: Connected to GND of HC-05 Bluetooth Module, Servo, 5V Relay, IR Sensor, MKE-M08 LCD2004 I2C Module, and 24/12V Buck Converter.
- 5V: Connected to 5V of MKE-M08 LCD2004 I2C Module, Servo, 5V Relay, and IR Sensor.
- A4: Connected to SDA of MKE-M08 LCD2004 I2C Module.
- A5: Connected to SCL of MKE-M08 LCD2004 I2C Module.
- D0: Connected to TXD of HC-05 Bluetooth Module.
- D1: Connected to pin2 of 1000 Ohms Resistor.
- D2: Connected to out of IR Sensor.
- D3: Connected to In of 5V Relay.
- D9: Connected to PWM of Servo.
HC-05 Bluetooth Module
- GND: Connected to GND of Arduino UNO.
- VCC: Connected to Normally Open of 5V Relay.
- TXD: Connected to D0 of Arduino UNO.
- RXD: Connected to pin1 of 1000 Ohms Resistor.
Servo
- GND: Connected to GND of Arduino UNO.
- VCC: Connected to 5V of 24/12V Buck Converter.
- PWM: Connected to D9 of Arduino UNO.
5A Fuse
- 1: Connected to 12v + of 12V 5Ah Battery.
- 2: Connected to pin2 of DIP Switch 1 Position.
24/12V Buck Converter
- VIN+: Connected to pin1 of DIP Switch 1 Position.
- VIN-: Connected to 12v - of 12V 5Ah Battery and NEG of 2.1mm Barrel Jack with Terminal Block.
- 5V: Connected to + of Electrolytic Capacitors, 5V of MKE-M08 LCD2004 I2C Module, VCC of Servo, VCC of 5V Relay, and Common terminal of 5V Relay.
- GND: Connected to GND of Arduino UNO, GND of HC-05 Bluetooth Module, GND of Servo, GND of 5V Relay, GND of IR Sensor, and - of Electrolytic Capacitors.
IR Sensor
- out: Connected to D2 of Arduino UNO.
- gnd: Connected to GND of Arduino UNO.
- vcc: Connected to 5V of 24/12V Buck Converter.
MKE-M08 LCD2004 I2C Module
- GND: Connected to GND of Arduino UNO.
- 5V: Connected to 5V of 24/12V Buck Converter.
- SDA: Connected to A4 of Arduino UNO.
- SCL: Connected to A5 of Arduino UNO.
5V Relay
- Normally Open: Connected to VCC of HC-05 Bluetooth Module.
- Common terminal: Connected to 5V of 24/12V Buck Converter.
- In: Connected to D3 of Arduino UNO.
- GND: Connected to GND of Arduino UNO.
- VCC: Connected to 5V of 24/12V Buck Converter.
2.1mm Barrel Jack with Terminal Block
- POS: Connected to pin1 of DIP Switch 1 Position.
- NEG: Connected to VIN- of 24/12V Buck Converter and 12v - of 12V 5Ah Battery.
DIP Switch 1 Position
- 1: Connected to POS of 2.1mm Barrel Jack with Terminal Block.
- 2: Connected to pin2 of 5A Fuse.
12V 5Ah Battery
- 12v +: Connected to pin1 of 5A Fuse.
- 12v -: Connected to VIN- of 24/12V Buck Converter and NEG of 2.1mm Barrel Jack with Terminal Block.
Electrolytic Capacitors
- -: Connected to GND of 24/12V Buck Converter.
- +: Connected to 5V of 24/12V Buck Converter.
Resistors
1000 Ohms Resistor
- pin1: Connected to RXD of HC-05 Bluetooth Module.
- pin2: Connected to D1 of Arduino UNO and pin1 of 2000 Ohms Resistor.
2000 Ohms Resistor
- pin1: Connected to pin2 of 1000 Ohms Resistor.
- pin2: Connected to GND of 24/12V Buck Converter.
Documented Code
#include <Servo.h>
const int trigPin = 7;
const int echoPin = 6;
const int servoPin = 9;
const int bluetoothRx = 10;
const int bluetoothTx = 11;
Servo lockerServo;
long duration;
int distance;
char bluetoothData;
void setup() {
lockerServo.attach(servoPin);
lockerServo.write(0);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
distance = getDistance();
if (distance <= 50) {
if (Serial.available()) {
bluetoothData = Serial.read();
if (bluetoothData == 'U' || bluetoothData == 'u') {
unlockLocker();
} else if (bluetoothData == 'L' || bluetoothData == 'l') {
lockLocker();
}
}
}
delay(500);
}
int getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
return