Typos in Reference: Port Manipulation

...seems to have some typos in the "Examples" section. Since the bottom of that page says "Corrections, suggestions, and new documentation should be posted to the Forum", I didn't just change the Wiki text, though I wanted to ( :slight_smile: ).

PORTB and PINB are mentioned there, but I think for consistency they should be PORTD and PIND. Am I right? Verbatim excerpt follows.

==
Examples

Referring to the pin map above, the PortD registers control Arduino digital pins 0 [ch65533] 7.

You should note, however, that pins 0 & 1 are used for serial communications for programming and debugging the Arduino, so changing these pins should usually be avoided unless needed for serial input or output functions. Be aware that this can interfere with program download or debugging.

DDRD is the direction register for Port D (Arduino digital pins 0-7). The bits in this register control whether the pins in PORTD are configured as inputs or outputs so, for example:

DDRD = B11111110; // sets Arduino pins 1 [ch65533] 7 as outputs, pin 0 as input
DDRD = DDRD | B11111100; // this is safer [ch65533] it sets pins 2 to 7 as outputs
// without changing the value of pins 0 & 1, which are RX & TX
//See the bitwise operators reference pages and The Bitmath Tutorial in the Playground

PORTB is the register for the state of the outputs. For example;

PORTD = B10101000; // sets digital pins 7,5,3 HIGH

You will only see 5 volts on these pins however if the pins have been set as outputs using the DDRD register or with pinMode().

PINB is the input register variable It will read all of the digital input pins at the same time.