#include <avr/io.h>
#define READ_BIT(destiny, bit) (((destiny) >> (bit)) & 1)
#define SET_BIT(destiny, bit) (destiny) = (destiny) | (1 << (bit))
#define CLEAR_BIT(destiny, bit) (destiny) = (destiny) & ~(1 << (bit))
#define WRITE_BIT(destiny, bit, value) (destiny) = (value) ? SET_BIT((destiny), (bit)) : CLEAR_BIT((destiny), (bit))
#define TOGGLE_BIT(destiny, bit) (destiny) = READ_BIT((destiny), (bit)) ? CLEAR_BIT((destiny), (bit)) : SET_BIT((destiny), (bit))
int main(void){
SET_BIT(DDRC, DDC5); // Setting pin A5 as output
SET_BIT(DDRB, DDB5); // Setting pin 13 as output
CLEAR_BIT(DDRD, DDC3); // Setting pin 3 as input
SET_BIT(PORTD, PORTD3); // Enabling pin 3 pull-up resistor
for(;;){
WRITE_BIT(PORTC, PORTC5, READ_BIT(PIND, PIND3)); // Writing the state of pin 3 to pin A5
WRITE_BIT(PORTB, PORTB5, !READ_BIT(PORTC, PORTC5)); // Writing the negated state of pin A5 to pin 13
}
}