

In the photo below we can see the port name with yellow and the corespondent digital input/output pin with pink.

Se we will work with the port D which includes the digital pins D2 to D7. To know to which port is each pin assigned just google up a picture of the ATMEGA328 pin layout or just search it in the datasheet. You see, to each digital port is assigned a name. Type in DDRD which is the direction register of the D port of the Atmega328 chip. We open the datasheet PDF and open the search bar. We will talk a bit about the registers that control the digital outputs/inputs. For examble let's take a look at the ATMEGA328 datasheet, which is the microchip that the Arduino UNO uses.

In this way we can store information about any thing in our microcontroller. In this case the register has a 22 value in decimal format. If we have a logic "1" we have to raise the noumber "2" to the power representing the bit position or a 0 when the bit is a "0" logic and make the sum of all of them. If we want to convert this register binary value to decimal we would have to make the sum of each bit as we can see in the photo above. As you can see the LSB has a lower values than the MSB. LSB or LAST significant bit represents the lower values of the register and the MSB or most significant bit the higher. In the photo above we can see an 8 bit register. Registers are normally measured by the number of bits they can hold, for example, an "8-bit register" or a "32-bit register". In electronics, a flip-flop or latch is a circuit that has two stable states and can be used to store state information, in this case a logic "0" or "1". In digital electronics, especially computing, hardware registers are circuits typically composed of flip flops, often with many characteristics similar to memory. Here is a full list with all the register types. There are many types of registers like adress register, control, flags, etc. Arduino register control, timers and interruptions Arduino register format and control
