Controlling a 120V motor w/ 5 momentary switches

I am a geocacher and I am wanting to build a geocache using an old coke machine. My intentions are for the cacher to use 4 momentary NO buttons (the buttons on the coke machine) in a certain sequence in order to operate a motor that will vend a PVC "coke can" containing a key to open the coke machine.

I am really wanting to get this thing out into the world, but unfortunately, even with reading like crazy about Arduino, I am still unable to figure out how to make it happen. Can anyone give me a hand with the programming aspect of this project? I apologize for my inexperience, but would appreciate any help you can throw my way.

What I would like to happen is for the motor not to operate until the operator accomplishes a set sequence of the 4 momentary switches (ex. sw1,sw3,sw2,sw4). I do have a 5th switch that can be used as a reset if that is required, but other than that it will be unused.

If more info is needed, please let me know. I've got an Arduino UNO and a 4 relay board and other odd and end components. I can get ahold of any other components that I need to. Thanks again.

Richard

Here is an outline that might help:

const int PINLength = 4;
const int PIN[PINLength] = {1, 3, 2, 4};

int PINIndex = 0;

const int NumButtons = 4;
const int ButtonPins[NumButtons] = {3, 4, 5,6};
const int ButtonValues[NumButtons] = {1, 2, 3, 4};

void setup() {
  for (int i=0; i < NumButtons; i++)
      pinMode(ButtonPins[i], INPUT_PULLUP);
}

void loop() {
    int button = GetButtonPress();

   if (button == PIN[PINIndex]) {
      PINIndex++;
        if (PINIndex == PINLength) {
              PAYOUT();
             PINIndex = 0;
            }
    }
    else
         {
         PINIndex = 0;  // Wrong guess, start over
         if (button == PIN[0])
            PINIndex = 1;  //  Got the first one already
         }
    }


int GetButtonPress() {
      wait for all buttons to be un-pressed (HIGH).
      repeatedly check each button pin for LOW (pressed).  Return the first one found.
}

void PAYOUT() {
    give them the can
    }

Sorry for the long time away. Work and life has been busy and I haven't had much time for anything else. Finally getting back to this. Thank you for your quick response and help with this. I am starting to feel that I have taken on more than I can handle. I do want to learn more about arduino, but am wanting to get this particular project up and going as soon as possible.

When I verify the code you posted I get an error. Is there any way you can look at it and see what's up? I apologize for my ignorance, but that code is totally foreign compared to what I've been reading so I can't really troubleshoot it. Also, how would I need to set everything up physically to make it work. Again, thank you for helping with this. I am just trying to learn as I go with this one.

When I verify the code you posted I get an error.

You don't want to share that?

PaulS:

When I verify the code you posted I get an error.

You don't want to share that?

Are you saying share the error that I get or that I shouldn't have posted that?

In the functions GetButtonPress() and PAYOUT() there were some things that still need to be made, johnwasser was clear that he gave you an 'outline'.
If you comment // out the 'human language' in those functions it compiles fine.