From 85ab8117bdb4631de2826a015c2e0286e14e8f65 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Tue, 4 Mar 2025 17:24:12 +0100 Subject: [PATCH] ex03 works --- module00/ex03/main.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/module00/ex03/main.c b/module00/ex03/main.c index f219aa9..76f9f5a 100644 --- a/module00/ex03/main.c +++ b/module00/ex03/main.c @@ -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); } } \ No newline at end of file