void setup()
{
DDRD = DDRD | B00011100; // set direction bits for pins 2 to 4 to be OUTPUT, leave others untouched
//(xx | 00 == xx) same as pinMode(pin, OUTPUT)
//Port D 0-7 bits map to Digital Pins 0 to 7, but AVOID Serial Pins 0 & 1.
Serial.begin(9600); //used for debugging / status
}
void loop()
{
PORTD=PORTD | B00011100; // turn HIGH bits 2-4, bit 0 and 1 are unaffected
Serial.print("LEDS ON - PORTD in BINary="); // debug to show masking
Serial.println(PORTD, BIN); // debug to show masking
delay (1500);
PORTD=PORTD & B11100011; // turn LOW bits 2-4 bit 0 and 1 are unaffected
Serial.print("LEDS OFF - PORTD in BINary="); // debug to show masking
Serial.println(PORTD, BIN); // debug to show masking
delay (1500);
}