int d=0;
void setup() {
// put your setup code here, to run once:
DDRD=0b11111111;
// DDRD=0xFF; // The code is the same as above (this is in hexadecimal)
PORTD=0b00000001;
DDRB=0b00000000;
PORTB=0b00000011;
}
void loop() {
// put your main code here, to run repeatedly:
//if (PORTD==0x80)
if ((PINB&0b00000001)==0)
{
d=1;
}
if ((PINB&0b00000011)==0)
{
d=0;
}
if (PORTD==0x01)
{
d=0;
}
if (d==0)
{
PORTD=PORTD<<1;
}
if (d==1)
{
PORTD=PORTD>>1;
}
delay(1000);
}