// https://wokwi.com/projects/351674089577906776
// https://forum.arduino.cc/t/struct-of-pines/1067726
// 13, 10, 7 and 3
void setup() {
Serial.begin(115200);
Serial.println("hello world.\n");
pinMode(13 , OUTPUT);
pinMode(10 , OUTPUT);
pinMode(7 , OUTPUT);
pinMode(3 , OUTPUT);
}
void loop()
{
static unsigned char tt;
set4Bits(tt);
delay(474);
tt++;
}
// place theBits into output pins 13, 10, 7 and 3
void set4Bits(unsigned char theBits)
{
PORTB = (PORTB & 0xdb) | ((theBits & 0x8) << 2) | (theBits & 0x4);
PORTD = (PORTB & 0x77) | ((theBits & 0x2) << 6) | ((theBits & 0x1) << 3);
}