Mega ADK not performing correctly (SOLVED)

For starters, the program (no compile errors)

/* Arduino ADK run-time program
 * Author:    -omitted-
 * Last Mod:  1/30/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 35;   // will become TX2, currently PL0
 const int outPinR    = 36;   // currently PL1
 
 int debounce   = 40;   // number of ms to wait for debounce
 
 int readStatusL = LOW;  // Triggers on LOW
 int readStatusR = LOW;  // Triggers on LOW
 
 
 void setup()
 {
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
     digitalWrite(outPinL, LOW);    // LED off
     digitalWrite(outPinR, LOW);
 }
 
 void loop()
 {  
     readStatusL  = digitalRead(pedalL);
     
     if (readStatusL == HIGH)
     {
         delay(debounce);
         if (readStatusL == HIGH)
         {
             digitalWrite(outPinL, HIGH);
         }
         else
         {
             digitalWrite(outPinL, LOW);
         }
     }
     
     readStatusR  = digitalRead(pedalR);
     
     if (readStatusR == HIGH)
     {
         delay(debounce);
         if (readStatusR == HIGH)
         {
             digitalWrite(outPinR, HIGH);
         }
         else
         {
             digitalWrite(outPinR, LOW);
         }
     }
 }

Now the details of the circuit.

Above is the input from a transcription pedal. However since the pedal has not been fully cannibalized, I have replaced the normal switches with N.O. SPST switches. Now the way it is currently programmed, the R port in the above picture goes to the digital Port 3 (Pin 7) on the board while L goes to digital pin 2 (Pin 6) on the board. I have two LEDs connected to digital ports 48 and 49 (Pins 36 and 35), which terminate to ground. I should also mention the board is being powered via USB and the circuit shown above is on a bread board being powered with 10v. Now here is where things have been weird. Pressing either button turns on both LEDs (dimly). Now here is where it gets weirder. When using the ground on the breadboard as a reference, I see both outputs with a voltage of 1.6v while the input voltage is ~7.7v on the input of the pressed side, but it shows 1.6v on the other input (the side that the button is not pressed on). Even stranger is when I use Gnd from the board as the reference voltage. I see the ground on the bread board as .35v when nothing is pressed and -2v when a button is pressed. If you need more information please ask for it.

The ideal behavior is when the left button is pressed then the LED in digital port 49 (pin 35) lights up and when the right button is pressed then the LED in digital port 48 (pin 36) lights up. Currently the LEDs directly terminate to ground on the bread board. A quick reply would be appreciated

bumping

Am I reading that correctly that you are feeding 10V to an Arduino pin?

Where are your debug statements?

In what way isn't the program working?

The power source is 10v, but it should be feeding ~9v. I have already made the consideration of stepping down the voltage since it is a digital input after all.

I will use the debugger in the IDE as you suggested I should.

The program should be looking at the two inputs from the switches, debouncing the inputs then switching on the corresponding LED for each press. Currently the program is taking in the inputs, but will (seemingly) turn on both LEDs. I feel like this can be resolved as either a hardware issue or program one if I looked at the program behavior in the debugger

Feeding the Arduino voltages that exceed the VCC of the processor chip is a bad idea.

First, you're turning on the protection diodes on the pins, which is never a good idea. (Data sheet says so)
Second, you're pushing current through the protection diodes back into VCC, which is having an unknown effect on VCC, highly dependent on how much current the system is drawing from VCC.

If you MUST have 10V out there, add 4.7V zeners from the two inputs to ground, so that the voltage on those pins swings from near ground to about 4.7V. That will make the processor much happier.

I changed the supply voltage and voltage of the circuit to 5v but it is still showing weird behavior. however, I do have more information. First of all, I need to write HIGH to both inputs to turn on the internal pull-up resistors so I have a high impedance on my input. I have tested with and without this code and it still does not do what is intended. With the code it always sees the inputs as high but does not light the LEDs until one of the buttons is pressed then both LEDs are lit. I could not this "data sheet" you speak of, and where it says this is a bad idea. Anyways, without the code it performs the same. The questions I cannot answer are 1. Why do both LEDs turn on when the button is pressed and 2. Is there a better way to actively debug this other than using Serial.println statements and following the serial monitor output?

In the future, if you are referencing a data sheet could you please link it? I know the arduino website has info about the board, but afaik no formal data sheet, only a schematic and info about the board on a web page. I am used to seeing formal specifications in a document.

/* Arduino ADK run-time program
 * Author:    *omitted*
 * Last Mod:  2/10/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 18;   // will become TX2, currently PL0
 const int outPinR    = 19;   // currently PL1
 
 int debounce   = 20;   // number of ms to wait for debounce
 
 int readStatusL;
 int readStatusR;
 
 
 void setup()
 {
     Serial.begin(9600);
     Serial.println("Hello world");
     delay(2000);                        //verify on serial monitor
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
 }
 
 void loop()
 {  
     Serial.println(1);
     readStatusL  = digitalRead(pedalL);
     
     if (readStatusL == HIGH)
     {
         delay(debounce);
         if (readStatusL == HIGH)
         {
             digitalWrite(outPinL, HIGH);
             Serial.println(2);
         }
         else
         {
             digitalWrite(outPinL, LOW);
             Serial.println(3);
         }
     }
     
     readStatusR  = digitalRead(pedalR);
     
     if (readStatusR == HIGH)
     {
         delay(debounce);
         if (readStatusR == HIGH)
         {
             digitalWrite(outPinR, HIGH);
             Serial.println(4);
         }
         else
         {
             digitalWrite(outPinR, LOW);
             Serial.println(5);
         }
     }
 }

Newer code with debug statements

SOLVED:

New code

/* Arduino ADK run-time program
 * Author:    *omitted*
 * Last Mod:  2/10/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 18;   // will become TX2, currently PL0
 const int outPinR    = 19;   // currently PL1
 
 int debounce   = 20;   // number of ms to wait for debounce
 
 int readStatusL;
 int readStatusR;
 
 
 void setup()
 {
     Serial.begin(9600);
     Serial.println("Hello world");
     delay(2000);// Give reader a chance to see the output
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
     delay(2000);
//     digitalWrite(outPinL, LOW);    // LED off
//     digitalWrite(outPinR, LOW);
 }
 
 void loop()
 {  
     Serial.println(1);
     readStatusL  = digitalRead(pedalL);
     
     if (readStatusL == LOW)
     {
         delay(debounce);
         if (readStatusL == LOW)
         {
             digitalWrite(outPinL, HIGH);
             Serial.println(2);
         }
         else
         {
             digitalWrite(outPinL, LOW);
             Serial.println(3);
         }
     }
     
     if (readStatusL == HIGH)
         digitalWrite(outPinL, LOW);
     
     readStatusR  = digitalRead(pedalR);
     
     if (readStatusR == LOW)
     {
         delay(debounce);
         if (readStatusR == LOW)
         {
             digitalWrite(outPinR, HIGH);
             Serial.println(4);
         }
         else
         {
             digitalWrite(outPinR, LOW);
             Serial.println(5);
         }
     }
     
     if (readStatusR == HIGH)
         digitalWrite(outPinR, LOW);
 }

After doing more reading about setting the internal pull-up resistance on inputs, I was not reading carefully enough when it said it also sets the input to HIGH unless it is pulled down by an input (grounded). So I modified the code to trigger on LOW and redid the buttons so instead they connected the input through 10k to ground if the button was pressed and it works now.