void setup() {
//  Serial.begin(9600);
  DDRB=0x3F;
  DDRD |= 0xF0; // PORTD4-D7 il nibble basso
}

void loop() {
  // create labeled node with name A0 to access analog pin A0
  int a = analogRead(0);
  PORTB=a>>4;
  PORTD=(PORTD&0x0F)|((a&0x0F)<<4);
  delay (300);
}