Wrong input if USB powered.

ben0bi:
I drawed a schematic by hand, I will scan it in later. But I saw this problem on the schematic:

If I just plug a cable to the inputs wich is not connected to anything, it will also give this error input values...

On the schematic I saw, that I connected the buttons like this:

GND---10kOhm--+--Btn---PinX  <-- means the cable from button to pin has no ground line...

|
+5V-----------+




But I think I should do it like that here, not?



+5V------Btn--+--PinX <-- but here, the +5V has no ground line...is that "acceptable"?
              |
GND--10kOhm---+




is that the problem?

Definitely - the first circuit doesn't switch between 0V and 5V, it switches between 5V and open-circuit. An open-circuit input is an aerial picking up any signal from near by. You really don't want this!

You don't need the external resistors - just configure the internal pull-ups on the relevant pins and run them to buttons that switch to ground.