Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
timotheus mParticipant
Ok, I see what you mean.
I changed it to a different handler now..but still it doesnt work. When triggering interrupt 1 it even restarts and prints:
Start
Loop// **** INCLUDES ***** #include "LowPower.h" const int int_trigger_A = 2; // pd2 int0 const int wakeUpPin = 3; // pd3 int1 volatile boolean HANDLER_wakeUp = false; volatile boolean HANDLER_int_trigger = false; volatile int sleepmode = 1; long count; void wakeUp() { HANDLER_wakeUp = true; } void int_trigger() { HANDLER_int_trigger = true; } void setup() { pinMode(wakeUpPin, INPUT_PULLUP); pinMode(int_trigger_A, INPUT_PULLUP); Serial.begin(9600); Serial.println("Start"); delay(100); } void loop() { Serial.println("Loop"); delay(500); attachInterrupt(0, int_trigger_A, FALLING); attachInterrupt(1, wakeUp, FALLING);// Wake up when wake up pin is low. if (sleepmode == 1) { delay(100); LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); } if (sleepmode == 2) { delay(100); LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); } detachInterrupt(1); // Disable external pin interrupt on wake up pin. detachInterrupt(0); // Do something here // Example: Read sensor, data logging, data transmission. delay(100); if (HANDLER_int_trigger) { HANDLER_int_trigger = false; sleepmode = 1; Serial.println("int_trigger"); delay(500); } if (HANDLER_wakeUp) { HANDLER_wakeUp = false; sleepmode = 1; Serial.println("wakeUp"); delay(500); } if (digitalRead(int_trigger_A==LOW)) { sleepmode = 2; count++; Serial.println("count++"); } else { Serial.println(count); delay(500); sleepmode = 1; } }
timotheus mParticipantHI,
appreciate your reply. What do you mean there’s only a fraction of time?
I used the example where it’s done as far as I can see the exact same way besides that I’m using two interrupts.
What would you change to get it running? -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)