изменена инициализация кнопки

This commit is contained in:
KLASSENTS 2025-01-24 11:00:12 +07:00
parent 8a0cc3dded
commit aaa96bd13b
2 changed files with 4 additions and 6 deletions

View File

@ -101,6 +101,7 @@
#include <IRremote.hpp> #include <IRremote.hpp>
int SEND_BUTTON_PIN = BTN_BUILTIN; int SEND_BUTTON_PIN = BTN_BUILTIN;
int BTN_ACTIVE_STATE = HIGH;
int DELAY_BETWEEN_REPEAT = 50; int DELAY_BETWEEN_REPEAT = 50;
@ -118,7 +119,7 @@ void storeCode();
void sendCode(storedIRDataStruct *aIRDataToSend); void sendCode(storedIRDataStruct *aIRDataToSend);
void setup() { void setup() {
pinMode(SEND_BUTTON_PIN, INPUT_PULLUP); pinMode(SEND_BUTTON_PIN, INPUT);
Serial.begin(9600); Serial.begin(9600);
while (!Serial) while (!Serial)
@ -141,10 +142,7 @@ void setup() {
void loop() { void loop() {
// If button pressed, send the code. // If button pressed, send the code.
bool tSendButtonIsActive = (digitalRead(SEND_BUTTON_PIN) == LOW); // Button pin is active LOW bool tSendButtonIsActive = (digitalRead(SEND_BUTTON_PIN) == BTN_ACTIVE_STATE); // Button pin is active LOW
if (digitalRead(SEND_BUTTON_PIN))
Serial.println("pressed");
/* /*
* Check for current button state * Check for current button state
*/ */

View File

@ -93,7 +93,7 @@ uint8_t sNumberOfBits = 32;
bool sSendButtonWasActive; bool sSendButtonWasActive;
void setup() { void setup() {
pinMode(SEND_BUTTON_PIN, INPUT_PULLUP); pinMode(SEND_BUTTON_PIN, INPUT);
Serial.begin(9600); Serial.begin(9600);
while (!Serial) while (!Serial)