I´m using LowPower.h and PinChangeInt.h libraries to put my Arduino into the sleep mode every 8 seconds and then it wakes up, modifies a counter and it goes to sleep again, but also I need to wake it up when a button is pressed asynchronously.

I´ve reached to wake up the Arduino every 8 seconds using LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF) and, in other code, I´ve also reached to wake it up while it sleeps indefinitely with LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF) but I can´t combine that periodical awakening with the asynchronous awakening.

Here is my code:

void setup(){


    //Pines declaration

    loopsToSend = setTimeToSend();  //

    //The three async buttons 
    PCintPort::attachInterrupt(4, readOpinion,RISING);
    PCintPort::attachInterrupt(5, readOpinion,RISING);
    PCintPort::attachInterrupt(6, readOpinion,RISING);

void loop(){

    if(loops < loopsToSend ){

        byte opinionValue = readOpinion(); //This method must awake the Arduino ASYNC to give a value to the opinionValue var, write the result in the file and go to sleep 

        if(opinionValue != 0){
            Serial.println("Button pressed!");

            //Writing result in a file
        //Go to sleep 8 seconds
        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
        opinionValue = 0;
    else {

        if(opiniones > 0){
            //Send file using GSM module
            loops = 0;

Can anyone help me? Thanks


1 Answer 1


My aim was to attach multiple interrupts to my Arduino but my problem was that I didn´t know if when the board changed to sleep mode using LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF) then it could be awake using another interrupt instead of the timer.

The void loop() method must sleep the board every 8 seconds if no button is pressed. Aside there is a method that is called when a button is pressed, that´s because in the void setup () I´ve attached an interrupt using PCintPort::attachInterrupt(PIN_NUMBER, METHOD_TO_CALL,MODE);

OP (PinaGamer) posted this answer inside the question, hence the community wiki answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.