#define F_CPU 16000000
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdbool.h>
// I/O DEFINITIONS
#define D9 PB1
#define D10 PB2
#define D13 PB5
#define D9_SET_LOW (0 << D9) // Remember to use AND when clearing bits
#define D9_SET_HIGH (1 << D9) // OR when setting. XOR when toggling
#define D13_SET_LOW (1 << D13)
#define D13_SET_HIGH (1 << D13)
// PIN MODES
#define D9_SET_AS_OUTPUT (1 << D9) // D9 LED
#define D10_SET_AS_INPUT (0 << D10) // D10 BUTTON
#define D13_SET_AS_OUTPUT (1 << D13) // D13 IN-BUILT LED
#define BUTTON_PRESSED (PINB & (1 << D10))
void setup() {
// put your setup code here, to run once:
LED_INIT();
}
void loop() {
// put your main code here, to run repeatedly:
while (1){
if(BUTTON_PRESSED) {
PORTB |= (1 << D9);
}else{
PORTB &= (0 << D9);
}
};
}
void LED_INIT(void){
DDRB = D9_SET_AS_OUTPUT | D10_SET_AS_INPUT | D13_SET_AS_OUTPUT;
}