int i; // counter variable -- pgm outputs codes 00000 to 11111 in portB 0-7bits.
// Port B maps to Digital Pins 8 to 13, with two high bits not usable.
void setup()
{
DDRB = DDRB | B11111111; // set direction bits for pins 8 to 13,
//(xx | 00 == xx) same as pinMode(pin, OUTPUT) for pins 8 to 13
Serial.begin(9600);
}
void loop()
{
for (i=0; i<64; i++)
{ // 6 bits manipulated 0 to 63
PORTB = PORTB & B00000000 ; // clear out bits 8 - 13,
PORTB = PORTB | i; // combine the port information with the new information for LED pins
Serial.print("PORTB in BIN="); // debug to show masking
Serial.print(PORTB, BIN); // debug to show masking
Serial.print(". i="); // debug to show actual decimal number
Serial.println(i); // debug to show actual decimal number
delay(500);
}
}