Hi,
try this way:
The delay can be removed if you like;
void loop() {
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
delay(1000);
bitSet(PORTD, 6); // sets Arduino pins 6 outputs,1
delay(1000);
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
bitSet(PORTD, 7); // sets Arduino pins 7 outputs,1
delay(1000);
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
bitSet(PORTB, 0); // sets Arduino pins 8 outputs,1
delay(1000);
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 1); // sets Arduino pins 9 outputs,1
delay(1000);
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 2); // sets Arduino pins 10 outputs,1
delay(1000);
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 3); // sets Arduino pins 11 outputs,1
delay(1000);
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 4); // sets Arduino pins 12 outputs,1
delay(1000);
}
without delay:
void loop() {
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTD, 6); // sets Arduino pins 6 outputs,1
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
bitSet(PORTD, 7); // sets Arduino pins 7 outputs,1
PORTD = 0x3F & PORTD; // sets Arduino pins 6 and 7 outputs,0
bitSet(PORTB, 0); // sets Arduino pins 8 outputs,1
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 1); // sets Arduino pins 9 outputs,1
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 2); // sets Arduino pins 10 outputs,1
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 3); // sets Arduino pins 11 outputs,1
PORTB = 0xE0 & PORTB; // sets Arduino pins 8 to 12 outputs,0
bitSet(PORTB, 4); // sets Arduino pins 12 outputs,1
}
Or try this way:
void loop() {
for (int i = 0; i < 7; i++)
{
digitalWrite(i + 6, HIGH);
digitalWrite(i + 5, LOW);
delay(1000);
if (i == 6)
digitalWrite(i + 6, LOW);
}
}