Code: Select all
DDRB = 0xff;
Code: Select all
PORTB = 0xff;
Code: Select all
DDRB |= 1 << DDB2;
Set port D pin 2 as input
Code: Select all
DDRB &= ~(1 << DDB2);
Set port B pin 2 to 1 (ON)
Code: Select all
PORTB |= _BV(PB2);
Code: Select all
PORTB |= 1 << 2;
Code: Select all
PORTB |= 1 << PINB2;
Set port B pin 2 to 0 (OFF)
Code: Select all
PORTB &= ~_BV(PB2);
Code: Select all
PORTB &= ~(1 << 2);
Code: Select all
PORTB &= ~1 << PINB2;
Code: Select all
if (PIND & (1<<PIND3))
{
...
}
Check if port D pin 3 equal to 0 (OFF
Code: Select all
if (!(PIND & (1<<PIND3)))
{
...
}