Wake up an Adafruit Feather 32u4 from Sleep Mode with an External Interrupt

Hello there,
I have an Adafruit Feather ATMega 32u4. I want to put it into sleep mode and wake it up with pressing a switch as an external interrupt. This is what I tried so far and which worked:

  1. switching a LED on and off with the switch
  2. putting the Adafruit to sleep and let it wake up with a watchdog timer. I tried to combine the code examples that I found in the Internet to make the code fit my board. I manage to put it to sleep but then I have to reset it because the Interrupt doesn’t work.

I would be very happy for any help and please don’t blame me, I am a complete beginner!

Here is my code:

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h>

int pin2 = 2;

void pin2Interrupt(void) {
/* This will bring us back from sleep. */


void enterSleep(void){
/* Setup pin2 as an interrupt and attach handler. */


attachInterrupt(digitalPinToInterrupt(2), pin2Interrupt, RISING);

if (digitalRead(pin2)){

/* The program will continue from here  
   First thing to do is disable sleep. */

void setup(){

/* Setup the pin direction. */
pinMode(pin2, INPUT_PULLUP);>

Serial.println("Initialisation complete.");

int seconds=0;

void loop(){

Serial.print("Awake for ");
Serial.print(seconds, DEC);
Serial.println(" second");

if(seconds == 3){
Serial.println("Entering sleep");
seconds = 0;

attach the interrupt before sleep, not after