motorized drawers

Hi,
I'm a complete newbie to arduino and so sorry if there is a obvious answer.
I am about to build a dresser and want to have the drawers motorized so when i impute a code example 1234#1 it opens the first drawer 1234#2 it opens the second drawer etc. etc.
I have found a keypad lock tutorial on youtube How to Make a Keypad Lock With an Arduino - YouTube so i was wondering if there is a simple way to modify the code to my needs.

Cheers

If you want people to look at code post it here.

And please use the code button </> so your code looks like this and is easy to copy to a text editor.

I presume you know how to get the Arduino to activate the drawer movement if it gets the right code.

If there is no requirement for a security code it would be much easier just to press a different button for each drawer..

...R

Along with code tags, your links would be easier to use if you used "Insert a link" button. I'm not sure what characters belong in the YouTube URL.

How to Make a Keypad Lock With an Arduino - YouTube sorry i hope the link works this time

// How to Make an Arduino Keypad Lock
// Jlaservideo.com

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

Servo ServoMotor;
char* password = "159";  // change the password here, just pick any 3 numbers
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 RedpinLock = 12;
int GreenpinUnlock = 13;

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);
}
}

here's the code he uses. Robin2 I would like to have the security code but if it would be too much of a hassle i can give that up.

Cheers

I only questioned the password because typing a password is tedious.

I suspect there are dozens of ways to approach this problem.

One option might be to use the first character to identify the drawer (so, 1,2,3 or 4) and the remaining characters to represent the password.

Then you could store the first character in a drawerNum variable before comparing the next 3 to the password as at present. That should require very little change to the existing code.

Before posting more code please use the AutoFormat option to lay it out clearly.

...R