Question on the Arduino zero sleep mode

Hello i have a question i got the sleep mode sketch from Nick Gammon website and works great on my uno and mega i never tried it on my Due and now i finally got a Zero in i was wondering before i try it would the same Sketch for the Sleep mode work on the Zero? Not sure and don't want to try it into i can figure it out so i don't screw it up board cost me enough and i can't replace it like a uno or mega.

Hello I just got th Arduino zero and I was wondering if the sleep mode function will work the same way as in the uno and mega?

The Zero runs on a SAMD21 CPU that is a completely different beast compared the ATMega328/2560 that are on the Uno and the Mega. A sketch/library written for boards based on Atmega will surely not work on the Zero as is.

You can put the Zero to sleep (deep sleep) with:

Call this once:
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

And for every sleep cycle:
__WFI(); //Wait for interrupt

Now to wake it you have setup an interrupt:

attachInterrupt(intPin, wakeISR, HIGH);

where wakeISR() is some ISR function
e.g. a simple blink:
void wakeISR()
{
digitalWrite(13, HIGH);
delayMicroseconds(500000);
digitalWrite(13, LOW);
}

Now the default attachInterrupt() method does not setup
the interrupts for wake up. This can be done with:

EIC->WAKEUP.reg |= (1 << digitalPinToInterrupt(intPin));

There is also a wait for event instruction: __WFE() but
I haven't been able to get this to work correctly.

Also note that when you put the board in sleep mode it
becomes unresponsive, at least on the Native USB port.
I suggest putting a delay (10s or so) in setup so you
will have time to upload a new sketch after a reset.