Arduino-Based Keypad Controlled Servo System
In this project, we will design and implement an Arduino-based servo control system using a 4×4 keypad. The keypad acts as an input interface to control the servo motor, allowing users to enter specific commands to move the servo to predefined angles. This project can be applied in various domains such as security systems, automated locks, robotics, and access control.
Arduino Uno
4×4 Matrix Keypad
SG90 Servo Motor
Jumper Wires
Power Supply (5V USB or Battery)
Breadboard (optional for better wiring management)
The 4×4 keypad consists of 16 keys arranged in a matrix form (4 rows and 4 columns).
When a key is pressed, it sends a signal to the Arduino, which then processes the input.
The Arduino is programmed to interpret specific key inputs and move the servo motor to a corresponding angle.
For instance, pressing ‘1’ may rotate the servo to 0 degrees, ‘2’ to 45 degrees, and so on.
The servo motor is driven using PWM (Pulse Width Modulation) signals from the Arduino, enabling smooth and precise movements.
Keypad to Arduino:
Row 1 → Digital Pin 2
Row 2 → Digital Pin 3
Row 3 → Digital Pin 4
Row 4 → Digital Pin 5
Column 1 → Digital Pin 6
Column 2 → Digital Pin 7
Column 3 → Digital Pin 8
Column 4 → Digital Pin 9
Servo to Arduino:
Signal (Orange) → Digital Pin 10
VCC (Red) → 5V
GND (Brown) → GND
#include <Servo.h>
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8, 9};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
Servo myServo;
void setup() {
myServo.attach(10); // Servo connected to pin 10
myServo.write(90); // Set initial position to 90 degrees
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
if (key >= '0' && key <= '9') {
int angle = (key - '0') * 20; // Mapping digits 0-9 to angles 0-180
myServo.write(angle);
}
}
}
Electronic Lock System: The keypad can be used to input a password to control the servo, which acts as a locking mechanism.
Robotics: Servo-controlled robotic arms that require precise movement.
Automation: Used in industrial and home automation where specific input triggers an action.
Security Systems: Implemented in access control systems to open/close doors or compartments.
This Arduino-based keypad-controlled servo system is a simple yet effective method to implement controlled movement using a user interface. With modifications, it can be expanded to include LCD displays, multiple servo control, and even IoT-based remote access. Whether used in robotics, security, or automation, this project serves as a foundational step in learning embedded systems and mechatronics.
This project can be applied in various domains such as security systems, automated locks, robotics, and access control.