I have this weird thing that I don't understand. I am using the Button code that is supplied with the Arduino IDE in the example sections and I followed the circuitry shown on the link in the code comments but I have this weird problem so that instead of the button doing anything it only turn the light off if I remove the wire from pin 2.
It sounds like you have the button wired incorrectly so that the button circuit is always closed.
If you are using one of those small (6mm) tactile buttons with 4 pins, be sure to always wire it across the diagonal, rather than straight across.
How do I put it in diagonal it doesn't seem like it supposed to do that
The small tactile button case is usually rectangular in shape and the pins on the long edge are connected together, whereas the pins on the short edge will be across the contacts. (At least the switches I have are that way) What ChrisTenone was telling you to use the pins from opposite corners for the connections, not to mount the switch diagonally.
If your button is similar to this, you will see 4 pins, connect you two wires to diagonally opposite pins, this will ensure you have a connection to each side of the switch.
Use connection as indicated below.
These buttons are constructed with pairs of pins connected together, one pair on each end of switch.
They look similar but the pins are closer in the center
I may have asked the wrong thing I can take the wire connected to pin 2 out of the bread board and the light is still turned on the only way it will actually turn off is if i remove the wire from pin two. I have an arduino mega so that might be the problem?
* 10K resistor attached to pin 2 from ground
Did you do that?
I have an arduino mega so that might be the problem?
No it is not. You are simply not wiring the button up correctly.
I can take the wire connected to pin 2 out of the bread board and the light is still turned on the only way it will actually turn off is if i remove the wire from pin two.
Yes that means you are simply not wiring the button up correctly.
Want me to say it again in case you missed it?
You are simply not wiring the button up correctly.
If you don't have the manufacturer's datasheet for the switch you can use a multimeter to "Ohm it out" and see how it works and figure-out which pins to use.
You can also make a continuity tester with a power supply (or battery), and LED, and a resistor. But if you are an electronics hobbyist, it's a really good idea to have a multimeter. (And a cheap multimeter is better than no multimeter.)