I'm trying to write PORTB and PORTD in ATmega328P using byte system like this,
// PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0
// N N N N N U U U
// 7 6 5 4 3 2 1 0
//======================================
// PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
// X X 1 1 1 1 1 1
// C C 13 12 11 10 9 8
//======================================
//C-Crystal Pins/U-Un used/N-Used/X-unknown value
byte pins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
//uint16_t style1=1365; //10101010101
//uint16_t style2=682; //01010101010
void setup() {
for (int i = 0; i < 11; i++) {
pinMode(pins[i],OUTPUT);
PORTD=B00000000;
PORTB=B00000000;
}
}
void loop() {
PORTD=B10101000;
PORTB=B00101010;
delay(1000);
PORTD=B01010000;
PORTB=B00010101;
}
According to this , Port value should be swapped. But, It's still remaining given value of the code before delay()
What is the problem in this code?