enum : uint8_t {LSB, MSB};
union intByte {
uint16_t uint;
uint8_t byte[2];
};
void setup() {
// put your setup code here, to run once:
DDRB |= 0b00111111;
DDRD |= 0b11110000;
}
void loop() {
// put your main code here, to run repeatedly:
static intByte potVal;
potVal.uint = 16 * analogRead(A0);
PORTB = PORTB & 0b11000000 | potVal.byte[MSB];
PORTD = PORTD & 0b00001111 | potVal.byte[LSB];
delay(50);
}