aboutsummaryrefslogtreecommitdiff
path: root/sem4/embedded/m1/int/int.ino
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-06-07 23:40:14 +0200
committerJulian T <julian@jtle.dk>2020-06-07 23:40:14 +0200
commit6075c41624efa8260344dfd4b0c7fa563f4cfe5e (patch)
tree0ee0942543935c70ddd108f71562612cdd72daee /sem4/embedded/m1/int/int.ino
parent6cb9bec1e0241fe64afdad9a520f026a9c25ea91 (diff)
Added solutions for many of the first exercises
Diffstat (limited to 'sem4/embedded/m1/int/int.ino')
-rw-r--r--sem4/embedded/m1/int/int.ino22
1 files changed, 12 insertions, 10 deletions
diff --git a/sem4/embedded/m1/int/int.ino b/sem4/embedded/m1/int/int.ino
index 8978be7..c4a2c31 100644
--- a/sem4/embedded/m1/int/int.ino
+++ b/sem4/embedded/m1/int/int.ino
@@ -4,19 +4,21 @@
#define DEBOUNCE 1
ISR(INT0_vect) {
- static bool state = 0;
+ static unsigned long last = 0;
- // Toggle LEDPIN
- digitalWrite(LEDPIN, state);
- state = !state;
+ unsigned long now = millis();
+ if (now - last < 100) {
+ return;
+ }
+ last = now;
+
+ static unsigned char state = 0;
- /*
- for(long i = 0; i < 1000; i++) {
- Serial.print("Hej ");
- Serial.println(i);
+ // Toggle LEDPIN
+ digitalWrite(LEDPIN, state % 2 == 0);
+ state++;
+ Serial.print("Hej "); Serial.println(state);
- }
- */
}
void setup() {