aboutsummaryrefslogtreecommitdiff
path: root/sem4/embedded
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-02-05 21:06:10 +0100
committerJulian T <julian@jtle.dk>2020-02-05 21:06:10 +0100
commita362090c5a5c13f422385d69ce7f64fa13c09b9f (patch)
tree48554d5af6fdec2ed115b67c46a822dcbdde51c1 /sem4/embedded
parent41773c52a88ca186df6031248a63dda3c9c29e05 (diff)
Added some exercise solutions
Diffstat (limited to 'sem4/embedded')
-rw-r--r--sem4/embedded/m1/int/int.ino47
1 files changed, 47 insertions, 0 deletions
diff --git a/sem4/embedded/m1/int/int.ino b/sem4/embedded/m1/int/int.ino
new file mode 100644
index 0000000..8978be7
--- /dev/null
+++ b/sem4/embedded/m1/int/int.ino
@@ -0,0 +1,47 @@
+#define LEDPIN 13
+#define BUTTONPIN 2
+
+#define DEBOUNCE 1
+
+ISR(INT0_vect) {
+ static bool state = 0;
+
+ // Toggle LEDPIN
+ digitalWrite(LEDPIN, state);
+ state = !state;
+
+ /*
+ for(long i = 0; i < 1000; i++) {
+ Serial.print("Hej ");
+ Serial.println(i);
+
+ }
+ */
+}
+
+void setup() {
+
+ // We need to talk
+ Serial.begin(9600);
+
+ // Setup pinmodes
+ pinMode(LEDPIN, OUTPUT);
+ pinMode(BUTTONPIN, INPUT_PULLUP);
+
+ // Attach a interrupt on the button
+ //attachInterrupt(digitalPinToInterrupt(BUTTONPIN), testy, RISING);
+
+ // Enable interrupt 0
+ EIMSK |= 1 << INT0;
+ // Eable on rising edge
+ EICRA |= (1 << ISC01) | (1 << ISC00);
+
+}
+
+void loop() {
+ static int i = 0;
+
+ //Serial.print("Cool stuff happening now ");
+ //Serial.println(i++);
+
+}