stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.86k stars 979 forks source link

digitalWrite(LED_BUILTIN,0) has inverted logic #2579

Closed FabioM3 closed 3 days ago

FabioM3 commented 4 days ago

Describe the bug The logic on "digitalWrite(LED_BUILTIN, 0)" is inverted, when I use an external led it works, but for the LED_BUILTIN it turns OFF the led with 1 and ON with 0.

To Reproduce

`#define botaoLigaDesliga A3 short ligado = 0; unsigned long tempoPassadoBotao = 0;

void setup() { pinMode(botaoLigaDesliga, INPUT_PULLDOWN); pinMode(LED_BUILTIN, OUTPUT);

digitalWrite(LED_BUILTIN, ligado); }

void loop() { if (digitalRead(botaoLigaDesliga)) { if (millis() - tempoPassadoBotao >= 2000) { if (ligado) { ligado = 0; } else { ligado = 1; }

  digitalWrite(LED_BUILTIN, ligado);
  tempoPassadoBotao = millis();
  Serial.print("Botão apertado - ");
  Serial.println(ligado);
}

} }`

Steps to reproduce the behavior:

  1. Plug.
  2. Press BTN on A3 to change the state of the led.
  3. See on serial the 0 or 1 and compare with the led.

Expected behavior The led needs to be OFF with 0 and on with 1.

Desktop (please complete the following information):

image