(solved)what's means about "PINB |= 1<<5"

I believe your understanding is correct.

A bit of background (I am using I/O to mean a physical pin on the chip to avoid confusion with the PIN register).

There are 3 registers that control any given I/O on the chip:

PIN = input register
PORT = output register
DDR = direction register.

The direction register controls whether an I/O is an input or an output. Behind the scenes pinMode(pin); uses this register.
The input register is what you use to read the current state of the I/O. If the I/O is an input PIN returns the value of whatever is connected, if it is an output, PIN returns the value in PORT.
The output register is what you use to set the state of an I/O. If the I/O is an output, PORT sets it to be a 1 or a 0. If the I/O is an input, PORT sets whether or not the internal pullup is enabled.

If the DDR register is set to Output, and you try to write to the PIN register, the I/O toggles such that if the output state is a 1, it becomes a zero and vice versa.

1 Like