programming a 2-pin button

I have a button(I will be more specific and post a picture if asked to) that has 2 outgoing pins
lets say I connect them to arduino uno's pin 7 and 8 what code should I use to read the button input?(like to check if the button is pressed)
any help would be much appriciated! XD

Please be more specific and post a picture (just kidding),

To get started you should use something like this. YOu can augment this by holding the state of every line so the printstatement is just printed once every press.

#define PIN1 7
#define PIN2 8

void setup()
{
  Serial.begin(9600);
  pinMode(PIN1, INPUT);
  pinMode(PIN2, INPUT);
  Serial.println("Start");
}

void loop()
{
  if (digitalRead(PIN1) == HIGH) 
  {
    Serial.println("pin 1");
  }
  if (digitalRead(PIN2) == HIGH) 
  {
    Serial.println("pin 2");
  }
}

A more complex if could be: if (digitalRead(PIN1) == HIGH && digitalRead(PIN2) == HIGH)

-- update

YOu must connect the common of the button to the +5V and use a pulldown resistor (10Kohm) between pin 7 and ground (idem for pin 8) to get things working.

First of all thanks for fast replying and it uses 2 pins but only one for data(I assume) so only one should matter but I can check that by myself
and does that mean that when a button is pressed its expressed as "HIGH" and when not pressed its "LOW"
just like when a LED is on or off?

Maybe you better post the picture after all.

check - http://arduino.cc/it/Tutorial/HomePage - section 2 - there 50+ sample sketches there to learn how Arduino works. Time spent there is not lost !

I have the board the button and the resistor but not the breadboardd
can I somehow do that without the breadboard?
and what do you mean connect it to a 5v? how? and I thought that arduino gets 5v from the 5v battery/usb

it uses 2 pins but only one for data

Buttons don't usually do data, other than the usual on/off - is this "button"device something like the one-wire memories sometimes used as ID tags in retail?

Like this:
http://www.maxim-ic.com/products/ibutton/

If you follow the scheme on - http://arduino.cc/en/Tutorial/Button - you don't necessary need the breadboard but put it on top of your shopping list!!
You can solder the wires or use ducttape or so; paperclips are also great tinkertoys :slight_smile:

no it does not have any kind of serial number/ID on it
im attaching a picture of my arduino uno and button connected please tell me what I should do to make it work keep in mind that all I have is arduino uno, nano that button, leds and many kinds of bugs and transistors/etc

Wire it to ground and use the internal pull-ups.
No extra external components needed.

I know Im annoying but I just started dealing with arduino about a week ago...
what do you mean?
I connect one pin to lets say pin 7 and what about the other? connect it to a transistor on one side and the transistor to an arduino power pin on its other side?

noooo
one side of the switch direct to 5V
the other to pin 7
if you like you could put 100 ohm resistor in either wire

how do I connect a pin to a 5v source?
I do have a 5v baterry but it has both red and black wires..and obviosly I would need to close the circuit...
so the main question would be how can I connect one pin to pin and one pin to a 5v source?

Noooo
One side of the switch direct to ground.
The other side to pin 7.
Enable the internal pull-ups - no need for external resistors.

what does "direct to ground" mean here?
and how do I enable internal pull-ups?

connect one side of the switch to socket marked GND

now I get it
GND socket = the lower hole in a socket? but I thought it didnt do anything...
would it help? Is it dangerous?
before I do this can you give me a code that will show its working?
remember its a push down button not a regular one, which means it can give 2 values(I assume HIGH and LOW)
would this work?:

void setup()
{
Serial.begin(9600);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(13, OUTPUT);
Serial.println("Start");
}

void loop()
{

if (digitalRead(7) == HIGH)
{
digitalWrite(13, HIGH);
}
else if (digitalRead(7) == LOW)
{
digitalWrite(13, LOW);
}
else
{
}

}

You've been on the forum now for six days.
You've posted questions about quadratic equations, ASCII decimal arithmetic, C pointer basics, DC motor control, LCD screen, and now how to wire up a switch.

Have you thought about laying down some good foundations, and trying some of the tutorials and playground examples (which cover in detail just about all of your topics so far)?

no... After this I will do that so thanks for the suggestion
but please answer my questions and I will do what you suggested

but I thought it didnt do anything...

It does - it completes the circuit (I know that wasn't a question, but you can have the answer for free)

would it help?

Yes. See above.

Is it dangerous?

Yes - the whole infrastructure of space-time will come crashing down around your ears.
(Only kidding)

if (digitalRead(7) == HIGH) 
  {
   digitalWrite(13, HIGH);
  }
else  if (digitalRead(7) == LOW)

If it wasn't HIGH when you read it the first time, then there's no real need to read it again such a short time later - a simple "else" will suffice.

Thanks I'll try everything you said!
and I used the arduino digital button example for the code, I hope it works