DigitalReadSerial not working

I dont know what the issue is but when I run the DigitalReadSerial example and check the Serial Monitor, the state is jumping between 1 and 0 randomly. Thats also the case with a simple jumper cable between D1 and GND. Why?

I tried two different mini USB cables and Arduino Nanos/
Running Windows 7

What version of the IDE are you using, which board, what op system, and a schematic of how you wire things would really help.

I guess you posted before my edit.

OS and board mentioned now.
1.6.5 version of the IDE.

As for wiring, its like this:

I just hooked up a Nano and compiled/ran the code and it shows a solid 0 from start to finish. Do you have the baud rate set correctly to 9600?

I didnt change the code, so its 9600 there. Also in the Serial Monitor. Is there anywhere else I have to set it?
Did you try connecting a jumper to D2 and GND? Thats where to odd stuff starts.

I set it up exactly as shown in your image...all zeroes.

If you set up like in the image shouldn't you be getting 1s?

stuka:
If you set up like in the image shouldn't you be getting 1s?

Explain your reasoning so it can be corrected.

isnt 1 HIGH and 0 LOW?
Either way, I'm getting random numbers dumped.

stuka:
isnt 1 HIGH and 0 LOW?
Either way, I'm getting random numbers dumped.

Show us a photograph of your setup. It's a hardware issue.

"Thats also the case with a simple jumper cable between D1 and GND. Why?"
Are you using D1 or D2?
Does the code match the hardware connections?
IF you think your USB connection is at question, add a line of text such as "testing". That will tell if the USB is working.

I must have missed your code. If you did not post it (inside code tags), please do so. Thanks

its the example program DigitalReadSerial, unchanged (File/Examples/Basics).
D2, like in the image.

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
  delay(1);        // delay in between reads for stability
}

"random" values are what you'd get if you were reading a pin that's not connected to anything... I suspect that somehow this is what's happening.

D2 is pin 2 right?
When connected to GND with that code it should be 1 and when not be 0, right? When connected I see 0 and 1 popping up.

I get solid zeros when grounded, random 1s & 0s when open. Try it with INPUT_PULLUP, I get solid ones or zeros.
Think you've got a bad connection.

Why random garbage when open? I don't understand the logic of that. For me its the opposite, which also doesnt make sense. I want to impement a simple push button. have 0 when its not pressed and 1 when it is (creates connection).
Is this not how you do it?

If there's nothing connected to a digital input pin, it acts like an antenna, picking up electrical noise and causing random 1s or 0s. If you want your button to show HIGH when pressed, connect one side to +5V, connect the other side to input pin, also you must connect a PULLDOWN resistor (4.7 to 10k) from pin to ground so its not an antenna when the button is not pushed, then do:
pinMode(2,INPUT);

I see, so resistor acts as a sensitivity reduction by cutting off very low voltages from various interference?

The INPUT_PULLUP and onboard resistor works fine.
Can I use 6 digital pins (buttons) connected to the GND by using the INPUT_PULLUP on all pins?
If I use an external resistor, do I need the same 10K before connecting to GND, or will I need "10*6"K?

You would need 6 Rs but button to GND and INPUT_PULLUP on each pin is the best way and remember your input state will be LOW when button pressed, but thats easy to work with.

Well 1 instead of 0 is no issue, if it can handle 6 inputs simultaneously.

Why do i need 6 Rs if using my own, instead of 1 with more resistance? Just curious.

Also, do I have this kind of interference with analog input?
Thanks.