Arduino Keypad With Motor – Tinkercad
Keypad-with-Servo-STech
Arduino Keypad With Motor – Tinkercad

This project is about setting up and configuring Arduino Keypad with Arduino Servo Motor. We can type the Password by Keypad if the Password is correct, then the MicroServo will turn around and the LED Green Light will be on, and if the password typed by Keypad is Wrong, then the Servo will not be opened and the LED Red Light will be on.

The TinkerCad Diagram

You can use this scenario for automated doors, gates, windows, and any other similar uses. All the steps have been explained in our YouTube Training Tutorial. Click here to watch it. The codes are as below.

#include <Servo.h>
#include <Keypad.h>
Servo ServoMotor;

char* password = "789"; 
//You can change the Passowrd

int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

// Create two variables for LED Lights
int RedpinLock = 12;
int GreenpinUnlock = 10;
void setup()
{
pinMode(RedpinLock, OUTPUT);
pinMode(GreenpinUnlock, OUTPUT);
ServoMotor.attach(11);
LockedPosition(true);
}
void loop()
{
char key = keypad.getKey();
if (key == '*' || key == '#')
{
position = 0;
LockedPosition(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
LockedPosition(false);
}
delay(100);
}
void LockedPosition(int locked)
{
if (locked)
{
digitalWrite(RedpinLock, HIGH);
digitalWrite(GreenpinUnlock, LOW);
ServoMotor.write(11);
}
else
{
digitalWrite(RedpinLock, LOW);
digitalWrite(GreenpinUnlock, HIGH);
ServoMotor.write(90);
}
}

Related Links

  • To watch the step by step YouTube tutorial Click Here
  • To access TinkerCad Project Click Here

SHARE

Share on facebook
Share on twitter
Share on whatsapp
Share on linkedin
Share on telegram
Share on email

1 thought on “Arduino Keypad With Motor – Tinkercad”

  1. Pingback: IoT Project, Setting up Keypad with the password - Soshiance Technology

Leave a Comment

Your email address will not be published.

You might also enjoy