     Serial.println(buttons_list[pressed_button].codeLen);
 
 }
-//============================================================
-// int lastButtonState;
-// int lastBtnStateOfBtn2;
-// int lastBtnStateOfBtn3;
-//============================================================
 
 int check_button_released(int button_index){
     return buttons_list[button_index].last_button_state == HIGH && buttons_list[button_index].button_state == LOW;

    return buttons_list[button_index].button_state;
}


void re_enable_IRIn_if_button_released(){

    if (check_button_released(0) | check_button_released(1))
    {
        Serial.println("Released a button");
        irrecv.enableIRIn(); // Re-enable receiver
    }
    return;

    buttons_list[1].last_button_state = buttons_list[1].button_state;
}

int check_button_pressed_and_sendCode(){
    int button_index = what_button_index_was_pressed();
    if (button_index != -1)
    {
        last_pressed_button = button_index; //marks the correct button_index as the last pressed
        Serial.print("Pressed Button ");
        Serial.print(last_pressed_button);
        Serial.println(", sending");

        digitalWrite(STATUS_PIN, HIGH);

        int is_repeating = buttons_list[button_index].last_button_state == buttons_list[button_index].button_state;
        sendCode(is_repeating, last_pressed_button);

        digitalWrite(STATUS_PIN, LOW);

        //return true
        return 1;
    }
    //return false
    return 0;
}

void loop()
{
    update_state_of_buttons();

    re_enable_IRIn_if_button_released();

    // If button pressed, send the code.
    if (check_button_pressed_and_sendCode())
    {
        delay(50); // Wait a bit between retransmissions
    }
    else if (irrecv.decode(&results))
    {
        printDadosBotao(last_pressed_button);
        digitalWrite(STATUS_PIN, HIGH);
        storeCode(&results, last_pressed_button);
        irrecv.resume(); // resume receiver
