H7 , is there any reason uno code does not work?

I am trying to learn H7 because of the industrial temp spec. and would like this code to run on the H7 but It only prints out hash tag or 7 in serial monitor and works fine on the uno r4 wifi. Does the breakout board have effects on the digital inputs I should know about? I have tried with and with out the breakout board. tks
/*Define input pins for DTMF Decoder pins connection /
void setup() {
Serial.begin(9600);
pinMode(3, INPUT); // connect to Std pin
pinMode(4, INPUT); // connect to Q4 pin
pinMode(5, INPUT); // connect to Q3 pin
pinMode(6, INPUT); // connect to Q2 pin
pinMode(7, INPUT); // connect to Q1 pin
}
void loop() {
uint8_t number_pressed;
bool signal ;
signal = digitalRead(3);
if(signal == HIGH) /
If new pin pressed */
{
delay(250);
number_pressed = ( 0x00 | (digitalRead(7)<<0) | (digitalRead(6)<<1) | (digitalRead(5)<<2) | (digitalRead(4)<<3) );
switch (number_pressed)
{
case 0x01:
Serial.println("Button Pressed = 1");
break;
case 0x02:
Serial.println("Button Pressed = 2");
break;
case 0x03:
Serial.println("Button Pressed = 3");
break;
case 0x04:
Serial.println("Button Pressed = 4");
break;
case 0x05:
Serial.println("Button Pressed = 5");
break;
case 0x06:
Serial.println("Button Pressed = 6");
break;
case 7:
Serial.println("Button Pressed = 7");
break;
case 0x08:
Serial.println("Button Pressed = 8");
break;
case 0x09:
Serial.println("Button Pressed = 9");
break;
case 0x0A:
Serial.println("Button Pressed = 0");
break;
case 0x0B:
Serial.println("Button Pressed = *");
break;
case 0x0C:
Serial.println("Button Pressed = #");
break;
}
}
}

There are several issues with your code that might be causing it not to work correctly. Here are the main problems and how to fix them:

  1. Incorrect Comment Syntax

You wrote:

if(signal == HIGH) / If new pin pressed */

This is incorrect. The /* ... */ format is for block comments, and // is for single-line comments. Fix it like this:

if(signal == HIGH) // If new pin pressed

  1. Incorrect Bit Shifting for number_pressed

Your line:

number_pressed = ( 0x00 | (digitalRead(7)<<0) | (digitalRead(6)<<1) | (digitalRead(5)<<2) | (digitalRead(4)<<3) );

This assumes that Q1 (pin 7) is the least significant bit (LSB) and Q4 (pin 4) is the most significant bit (MSB). However, if the wiring is reversed, the bit order might be incorrect. Try rearranging based on your wiring.

  1. Incorrect Case Values

You have:

case 7:

but everywhere else you use hex notation (0x01, 0x02, etc.).
case 7: should be case 0x07: to maintain consistency.

  1. Floating Inputs (Pull-Down Resistors Needed)

Since you are using pinMode(..., INPUT);, the inputs might be floating when not connected. Try enabling internal pull-down resistors using:

pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);

However, this assumes your keypad uses active LOW logic (buttons pull the signal to ground when pressed). If the logic is active HIGH, you'll need external pull-down resistors (10kΩ to GND).

  1. Debouncing Issue

You use:

delay(250);

This may not be enough for proper debouncing. Instead, use:

delay(50);
while(digitalRead(3) == HIGH); // Wait for the button to be released

This prevents false multiple detections.

Fixed Code

void setup() {
    Serial.begin(9600);
    pinMode(3, INPUT_PULLUP); // Connect to Std pin
    pinMode(4, INPUT_PULLUP); // Connect to Q4 pin
    pinMode(5, INPUT_PULLUP); // Connect to Q3 pin
    pinMode(6, INPUT_PULLUP); // Connect to Q2 pin
    pinMode(7, INPUT_PULLUP); // Connect to Q1 pin
}

void loop() {
    uint8_t number_pressed;
    bool signal = !digitalRead(3); // Active LOW logic (button press pulls LOW)
    
    if (signal) { // If new pin pressed
        delay(50);
        while (!digitalRead(3)); // Wait for button release (debounce)

        number_pressed = ( 0x00 | (digitalRead(7)<<0) | (digitalRead(6)<<1) | (digitalRead(5)<<2) | (digitalRead(4)<<3) );

        switch (number_pressed) {
            case 0x01: Serial.println("Button Pressed = 1"); break;
            case 0x02: Serial.println("Button Pressed = 2"); break;
            case 0x03: Serial.println("Button Pressed = 3"); break;
            case 0x04: Serial.println("Button Pressed = 4"); break;
            case 0x05: Serial.println("Button Pressed = 5"); break;
            case 0x06: Serial.println("Button Pressed = 6"); break;
            case 0x07: Serial.println("Button Pressed = 7"); break;
            case 0x08: Serial.println("Button Pressed = 8"); break;
            case 0x09: Serial.println("Button Pressed = 9"); break;
            case 0x0A: Serial.println("Button Pressed = 0"); break;
            case 0x0B: Serial.println("Button Pressed = *"); break;
            case 0x0C: Serial.println("Button Pressed = #"); break;
            default: Serial.println("Unknown button pressed"); break;
        }
    }
}

Thank You, will implement and try !

This will not work. Other then this it is a good answer.

Would this work instead?

pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);

Probably not! Without a schematic I can only guess. There are a lot of possibilities as to how you have wired it.