Go Down

Topic: Vidor 4000 LED_BUILTIN LOW is HIGH (Read 829 times) previous topic - next topic

yokonav

When I run following blink code it stays 10s on HIGH which is the opposite behavior.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH); 
  delay(2000);                       
  digitalWrite(LED_BUILTIN, LOW); 
  delay(10000);
}

I also checked the WifiNina > Ap_SimpleWebServer example and clicking on High link actually turns off the LED and vice versa. I also tried with 0 and 1 instead of LOW and HIGH respectively to see if constant values has changed.

cord_elias

Regarding to the schematic the cathodes of the user (RGB) led are driven by control signals (PB08 of SAM D21 is driving "R") whereas the anode is tight to Vcc (+3.3 V).
So the behavior you observe is what is to be expected with this hardware constellation ...
 

yokonav

#2
Dec 12, 2018, 11:14 am Last Edit: Dec 12, 2018, 11:16 am by yokonav
Is this intended behavior or hardware bug? I don't expect to see LED off when I set it to be HIGH in my code and vice versa.

pert

It's not a bug. Active LOW is quite common. You just need to get used to LOW being a state rather than assuming "HIGH means on".

I generally treat HIGH and LOW as "magic numbers" in my code. Something like this:
Code: [Select]

const byte LEDonState = LOW;
const byte LEDoffState = HIGH;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, LEDoffState);
  delay(2000);                       
  digitalWrite(LED_BUILTIN, LEDonState);
  delay(10000);
}

Go Up