bits and pins

I'm trying to make something like this: What i do not understand is how are byte values related to arduino pins. This guy is using 8 bits, but how are they mapped to pinout ports?

He is using direct port access, using PORTB, you can read a bit more about direct port access here:

Thank you, that helped. Now i'm clear what does PORTD do. However, PORTB remains mistery :)

So i have two more questions. What does pins 6 & 7 do with PORTD? What does PORTB = B00100000 activates? 13?

As i see it port map would look like this |PORTD | PORTB | |0 1 2 3 4 5 6 7| 8 9 10 11 12 13 __ __|

What does PORTB = B00100000 activates? 13?

Yes, but

PORTB |= (1<<PINB5);
PORTB |= B00100000;

is usually better because it doesn’t clear the other pins.

EDIT. Sorry typo, should have been |=


Yes, but

PORTB != (1<<5);

Better still:

PORTB |= (1<<5);


PORTB &= ~(1<<5);

to clear it.

I'm little bit confused now...I'm reading this: It says: "So if we write PORTD = B00110001; we have made pins 2,3 & 7 HIGH. "

Arent' 0,4,5 HIGH?

Yes, that is wrong - maybe it was referring to an earlier processor's pins, and not Arduino pins.

Ok. Everything is much clearer now.