ex03 works

This commit is contained in:
hugogogo
2025-03-04 17:24:12 +01:00
parent 1388ef3aa3
commit 85ab8117bd

View File

@@ -19,27 +19,17 @@
#define SW1 2
#define SW2 4
#define ON 1
#define OFF 0
#define SWITCH(state) state = (state == ON) ? OFF : ON;
int main() {
// FLASHING
MODE_OUTPUT(B, D1);
MODE_INPUT(D, SW1);
int state = OFF;
while(1) {
if (IS_PIN_SET(D, SW1)) {
SWITCH(state);
TOGGLE_PIN(B, D1);
_delay_ms(20);
while(IS_PIN_SET(D, SW1)) {
continue;
}
_delay_ms(20);
}
if (state) {
SET(PORTB, D1);
}
else {
CLEAR(PORTB, D1);
}
_delay_ms(100);
}
}