Using my arduino as an ISP i have programmed an Attiny45 to cycle up and down flipping the outputs (PB0-PB4) high and low lighting up LEDs in sequence.
My question: How does PORTB = (1 << x);
enable a PortB pin high if 'x is port zero, at logic low and there is no "1/high" bit to bitshift onto the byte/bit? Isnt it logically shifting in a zero out of thin air? I even tried setting the PortB register all to zero in the beginning of my code but it lights the LED's regardless.
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
int x = 0;
DDRB = 0b00111111;
PORTB = 0b00000000;
while(1){
while (x < 4){
PORTB = (1 << x);
_delay_ms(100);
x ++;
}
while (x > 0){
PORTB = (1 << x);
_delay_ms(100);
x--;
}
}
}