ex03 works
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user