Making Uno into arcade stick

so I am trying to do the most basic of basic, but I already might of broke one board (the people helping me seem to think the board is probably still good but I can't get it to upload) So new board, new attempt, I don't want to screw this up a second time.

My plan is to connect the 5.v from the board to the power rail of a breadboard and then each button connecting to that rail with one wire and the other wire from each button going to a different digital pin. The ground of the power rail will be connected to one of the power grounds (does it matter which?) for the optical stick which requires a 5v power source and it's own ground. Because the optical stick goes off (rather than on) when a direction is selected, I have a nand gate switching it so instead the direction inputted will turn on. This is going on the breadboard too and will require a spot on the powerrail, and on the ground rail and then the outputs from the gate will go directly to the remaining digital pins on the uno board.

My questions are, first is the above plan viable and reasonable?

Is there already code written that more or less does what I am trying to accomplish (with minor adjustments to the specific pin referenced in the sketch) ?

You will need pulldown resistors with that plan. Imagine what happens when the button is not pressed. What is the voltage on the Arduino input pin? It's the voltage of the air which is really not a reliable source of power.

It's usually better to use the built-in pullup resistors in the Arduino and have your buttons switch the pin to ground. That's why the original arcade stick works 'backwards' in your mind.

So the arcade stick that is on until something is pressed is best without the nand gate, and then for the buttons I should likewise wire them so their on until pressed? I'm not sure the best way to wire the buttons then.

How would I wire buttons that seem to just have on off to give power to the pin untill pressed?

More over though is there a sketch out there that does this? I don't want to reinvent the wheel programing wise.

This is one of the first Google image search results that I get:

This is using the internal pullup that can be set in your code:

#define MYPIN 2
void setup() {
  pinMode(MYPIN, INPUT_PULLUP);
}
void loop() {}

Oh I see. So the analog would work the way i was thinking for digital? off until button press?

'Off' and 'On' are sometimes problematic words to use.

With the internal pullup, digitalRead(MYPIN) will return HIGH if the button is not currently pressed and LOW when it is pressed. You might use this in code like...

if(digitalRead(MYPIN) == LOW) {
  //button is pushed
  //do some stuff
  //...
}

So far I am following you, but I'm still trying to figure out how to wire the actual stick part which has a separate wire for providing power to it and it's own ground. It uses high when a direction is not pressed and low when it is pressed, in the past I wired it to existing joystick boards using a nand gate because the previous boards wanted it to work the opposite. In this case, can I just wire them directly to the analog pins?

What voltage is pulling up the original pins? If the original button is 'not pressed' then what voltage do you measure with your multimeter? If it's over 5.5V then you can't just plug in the Arduino. A transistor such as a MOSFET will be required. If it's under, then you're good to go.

Thank you, that shouldn't be a problem then.