 
 }
 //============================================================
+// 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;
+}
+
+int check_button_pressed(int button_index){
+    return buttons_list[button_index].button_state;
+}
+
+
+
 void loop()
 {
     // If button pressed, send the code.
-    int firstButtonState = digitalRead(FIRST_BUTTON_PIN);
 
     //========================================================
+    buttons_list[0].button_state = digitalRead(FIRST_BUTTON_PIN);
+    buttons_list[1].button_state = digitalRead(SECOND_BUTTON_PIN);
+
     // int secondButtonState = digitalRead(SECOND_BUTTON_PIN);
     // int thirdButtonState = digitalRead(THIRD_BUTTON_PIN);
     //========================================================
 
-    if (lastButtonState == HIGH && firstButtonState == LOW)
+    if (check_button_released(0))
     {
         Serial.println("Released");
         irrecv.enableIRIn(); // Re-enable receiver
     }
 
-    if (firstButtonState)
+    if (check_button_pressed(0))
     {
         last_pressed_button = 0; //marca o primeiro botao como sendo o pressionado
         Serial.println("Pressed, sending");
         digitalWrite(STATUS_PIN, HIGH);
-        sendCode(lastButtonState == firstButtonState, last_pressed_button);
+        sendCode(buttons_list[0].last_button_state == buttons_list[0].button_state, last_pressed_button);
         digitalWrite(STATUS_PIN, LOW);
         delay(50); // Wait a bit between retransmissions
     }

    Serial.begin(9600);
    irrecv.enableIRIn(); // Start the receiver
    pinMode(FIRST_BUTTON_PIN, INPUT);
    // pinMode(SECOND_BUTTON_PIN, INPUT);
    // pinMode(THIRD_BUTTON_PIN, INPUT);
    pinMode(STATUS_PIN, OUTPUT);
}

// Storage for the recorded code
// int codeType = -1; // The type of code
// unsigned long codeValue; // The code value if not raw
// unsigned int rawCodes[RAWBUF]; // The durations if raw
// int codeLen; // The length of the code
// int toggle = 0; // The RC5/6 toggle state


// Stores the code for later playback





void printDadosBotao(int pressed_button){

    Serial.println("Dados Button");
    Serial.println("codeType:");
