Port Manipulation question

Hey, I'm trying to replace some of the digitalWrites in my code with port manipulation for speed reasons.

However, I'm wondering, how do you change the state of 1 pin without effecting the others? For example, if I set 1 pin HIGH, then a few seconds later, I want to set the pin next to it HIGH also, how can I leave the other pin HIGH without having to set it HIGH again?

Regards,
Dan

Use bitwise OR to set bits to 1 and bitwise AND to set bits to 0.

PORTB |= 0b00000110;  // Set bits 1 and 2 HIGH
PORTB &= ~0b00001010;  // Set bits 1 and 3 LOW (the '~' does a bitwise inversion changing 0b00001010 to 0b11110101)

Here's my thread on the same question:
http://arduino.cc/forum/index.php/topic,93737.0.html

I've been using the digitalWriteFast, which somehow is faster, smaller, and easier than port manipulation.
http://arduino.cc/forum/index.php/topic,93737.0.html

John_S:
I've been using the digitalWriteFast, which somehow is faster, smaller, and easier than port manipulation.
http://arduino.cc/forum/index.php/topic,93737.0.html

It's faster and smaller only if your pin numbers are compile-time constants. If your pin number is a variable then it will be the same speed as a regular digitalWrite().