door lock (help)

could someone give me the code source , how to command a servo-motor with a keypad
well the project is the servo will turn when we enter a true password (it's a door lock key)
thank you :slight_smile:

Try this!

http://lmgtfy.com/?q=arduino+door+lock+servo+keypad

thank you so much sir , but i dowloaded the code and there an error about the #include <keypad.h>
dhould i dowload the library of keypad and add it to sketch ?
sorry i am a bigginner in arduino

Please post the code, and separately post the error message. Follow these directions:

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!

hello , finally it works , thank you all member of forum am so hapnow just i want to add a buzzer which do an alarm
for a small periode of time when we enter a false password 3 time
i will show the code source just tell me how can i insert the code of a buzzer
thanks alot peoples

i will show the code source just tell me how can i insert the code of a buzzer

Put the cursor where you want the code to go, and start typing.

If you need help determining where to position the cursor, the order of events starts with you posting some code.

are you on the same school project as Abdulrahman_alrawi??

this is the code :
// letsarduino.com
// [Project 20] - Arduino Door Lock Using 4x4 Keypad and Servo Motor

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

Servo servo_Motor;
char* password = β€œ123”;
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] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int redPin = 12;
int greenPin = 13;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
servo_Motor.attach(11);
setLocked(true);
}

void loop()
{
char key = keypad.getKey();
if (key == β€˜*’ || key == β€˜#’)
{
position = 0;
setLocked(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
setLocked(false);
}
delay(100);
}
void setLocked(int locked)
{
if (locked)
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
servo_Motor.write(11);
}
else
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
servo_Motor.write(90);
}
}

Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)


so you copied and pasted the code from this page

and you are looking for more code to copy and paste?

I suggest you start adding something that will tell you how many false attempts have occurred.

then you can add the buzzer

this is the code :

Why
does
all
of
your
code
start
in
column
one?

Use Tools + Auto Format to properly indent it.

Use blank lines between functions. Do not jam them all together.

Under what conditions do you want the buzzer to do something? Under what conditions should it stop doing whatever it is you want it to do? What do you want it to do?

where should i insert the code to make a buzzer working when we enter false password 3 times
and which is the code

Achref-Abbassi:
where should i insert the code to make a buzzer working when we enter false password 3 times
and which is the code

in the loop()

if (nbConsecutiveErrors == 3) {buzz();}

Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

i did not anderstood your request sorry

i did not anderstood your request sorry

What part of it don’t you understand? Every post contains a number of links. The exact set of links depends on why you are and who wrote the post/reply. Yours contain links to Modify the post. Select that link. Highlight the code, and press the </> icon above the text entry field. Code tags will be added around the code. Click the Save button.

Or, do the same, but delete the code and reinsert it, AFTER using Tools + Auto Format. This is preferred.

hello , i made the project , but i want to add buzzer which do a sonor signal when we enter a false password 3 times
could someone how can i do it
(am asking about the code )
a few seconds ago

well i think that the password must be finished by a char (# for exemple)
which let the code count the number of trys
and make the signal after 3 false essai
this is what i think but sinse am a bigginer i don't know how can i tradict it in the code

Well you need to learn to program then.

We don't write code if you are not interested in learning... we can help you correct your personal code attempts at solving this pb

As already asked try to add avariable capturing the number of missed entry for example.

  • how and where would you declare it?
  • how and where would you initialize it?
  • how and where would you increase it?
  • how and where would you reset it?

thank you , am reading some books and am trying

hello
i have an idea : we enter password with keypad then
after entering β€œ#” the code compare which we entered and the password
if equals the motor move
if not equals a counter ++
and if nbressai == 3
buzzer (hight )
what do you think brothers