PIR example doesn`t wake Mega 2560?
-
So, I have tested the following:
Sketch on Mega 2560,
pin 3 with int1 - not working
pin 3 with int5 - not working
pin2, int0,4 - not working
pins 18-21, (digitalPinToInterrupt(DIGITAL_INPUT_SENSOR)) - not working
Sketch on UNO - works as it should!
So definitely something strange going on with 2560s interrupts.
Any advice? -
Then what does it do when sleep is issued?
Because the defined sleep-time still has to pass...and it does "nothing" till that, and that something cannot be broken by interrupt?
What should be the good method to catch an interrupt, or a motion, without going thru the main loop crazy fast?
Why cant it sleep? -
@vobi
i think mega2560 can go powerdown, but have not the hardware for testing.
What you could do for isolting the issue, is removing sleep and check if the interrupt triggers well (with a bool flag) -
-
I don't have this much deep knowledge on the chip, but my best guess is that there must be something different in the MEGA chip than the other on the at328p on the uno and mini pro. It could very well be that the MEGA is not designed to be a low power device, but I'll let others say something more appropriate :)
-
According to Mr. Nick Gammon, thats not the case (or I`m missing something):
Running from a 9V battery through the "power in" plug, it draws about 50 mA.
Running on 5V through the +5V pin, it draws about 49 mA.
(Note: around 68 mA on a Mega 2560 board)
Now we'll try putting it to sleep:
Sketch B#include <avr/sleep.h> void setup () { set_sleep_mode (SLEEP_MODE_PWR_DOWN); sleep_enable(); sleep_cpu (); } // end of setup void loop () { }Now the Uno draws 34.5 mA. A saving, but not a lot.
(Note: around 24 mA on a Mega 2560 board)
http://www.gammon.com.au/power