Are registers on my Arduino MEGA 2560 broken?

Hi,

I’ve bought cheaper version of Arduino Mega on Aliexpress. It looks the same, but I’m affraid, there’s problems with registers.

I wanted to test pins 8, 9 and 10. I’ve connected each of them to 5V via resistor, so when I read the value from the pin, there should be 1. Because power was connected through the resistor, when pin was connected to GND too, it should be in low mode.
And it worked for regular digitalRead functions, but I cannot figure out how to use B-register to read correct values…

I’ve written following code:

void setup() {
  Serial.begin(115200);
  
  for(int i = 2; i < 14; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);
  }

  for(int i = 8; i < 11; i++)
    pinMode(i, INPUT);

}

void loop() {
  Serial.println("===");
  Serial.print(DDRB);
  Serial.print(" ");
  Serial.print(PORTB);
  Serial.print(" ");
  Serial.println(PINB);
  Serial.print(PORTB & B00000001);
  Serial.print(PINB & B00000010);
  Serial.print(PINB & B00000100);
  Serial.println();
  Serial.print(digitalRead(8));
  Serial.print(digitalRead(9));
  Serial.print(digitalRead(10));
  Serial.println();

  delay(1000);
}

And I’ve got such output(clarified):

===
224 0 30
024
111
===
224 0 0
000
110
===
224 0 16
000
111
===
224 0 16
000
101
===
224 0 16
000
111
===
224 0 16
000
011
===
224 0 16
000
111

As you can see, digitalRead worked well, but I’ve had problems with B-registers…

Does it show that my Arduino is fraud?

Please include the code and output in your post, using code tags (use the </> button), and a schematic of how it’s wired.

On the Arduino MEGA, the mapping of arduino pins to ports/bits is much different than on an Uno. pins 8, 9, and 10 are in fact PORTH6, PORTH5, and PORTB4... So the bare PORTB code that you have now will certainly NOT work.