Arduino Mega Pin Issues in 0017

Hello, my first post here!
I got a Arduino Mega and this is my second problem with it and 0017.

the first problem was with the analogue pins solved here
<<in a link i can't post...>>

but now i have another issue:
When applying LOW to pin 42, both pin 42 and pin 43 are set to LOW

here's the code i ran to test this:
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.print("Pin 42 ");
Serial.println(digitalRead(42));
Serial.print("Pin 43 ");
Serial.println(digitalRead(43));
delay(1000);
}

and here are the results when pressing one button at a time:
Pin 42 1
Pin 43 0
Pin 42 1
Pin 43 0
Pin 42 1
Pin 43 0
Pin 42 0
Pin 43 0
Pin 42 0
Pin 43 0
Pin 42 0
Pin 43 0
Pin 42 1
Pin 43 0
Pin 42 1
Pin 43 0
Pin 42 1
Pin 43 0
Pin 42 0
Pin 43 0
Pin 42 0
Pin 43 0
Pin 42 0
Pin 43 0

i switched from pressing pin 43 down for 3 seconds, then to 42 for 3 seconds and so on.

for now i'll just use different pins but, is there a way to fix this (similar to the previously mentioned analogue fix?)

Thanks a bunch!

How're those pins wired up?

i have a wire going from pin 43 to a tactile push button to ground
also, i have a wire going from pin 42 to a different tactile push button to ground

Have you enabled the internal pull-ups for those two pins, or are they 'floating' when the switch is not pressed?

A 'floating' pin will pick up noise and read as a random value unless you use an external pull-up or pull-down resistor or enable the internal pull-up.

Lefty

i'm not exactly sure what that means... can you explain? thanks!

and this might help explain things....

i ran the code:
void setup(){
Serial.begin(9600);
}
void loop(){
for (int n =0; n < 53; n++){
Serial.println(digitalRead(n));
}
Serial.println("holy moly");
delay(5000);
}

with no buttons attached and got...

1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
0
0
0
1
0
1
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
0
0
holy moly

which doesn't make sense to me... but maybe this has something to do with what you mentioned!

oh crud~! i forgot the resistor for the button, but how does that explain the 2nd test i ran? (when all the pins were disconnected)

Add the following to the setup portion of your sketch:

pinMode(42, INPUT); // set pin to input
digitalWrite(42, HIGH); // turn on pullup resistors

pinMode(43, INPUT); // set pin to input
digitalWrite(43, HIGH); // turn on pullup resistors

from the reference:

Lefty

wooaah aweeesome!!!! thanks for all your insanely quick responses!!!!