DigitalWrite
-
Hello,
I am trying to use C to on the LED on my M5 stick c plus.
I have initialise pin 10 as the output, and when I send digitalWrite(led_pin, 0), it ons the LED.
My code causes the LED to on when 0 is sent, and off when 1 is sent. Any idea why it seemed like it is flipped? Thank you
-
Hello @sleepyfatcat
if you look at the schematic you'll see that the plus side of the LED is tied to VESP_3V3 and the negative side is tied to GPIO10. In order for the LED to light up the GPIO needs to go low. So nothing is wrong it's just how the LED is connected.
BTW: this is a common thing in electronics as it is easier (cheaper) to switch to GND.
Thanks
Felix -
This is a normal behaviour. Look at the schematic of the device: https://docs.m5stack.com/en/core/m5stickc_plus the LED is between GPIO 10 and +3.3V (I miss a resistor here but this makes no difference to your issue). As long as the port 10 is "High" (or "1") the LED is hanging between 3.3V and 3.3V from the port and cannot light up. If you set the port to "Low" ("0") the LED is between 3.3V and GND and light up.
-
@sleepyfatcat said in DigitalWrite:
Hello,
I am trying to use C to on the LED on my M5 stick c plus.
I have initialise pin 10 as the output, and when I send digitalWrite(led_pin, 0), it ons the LED.
My code causes the LED to on when 0 is sent, and off when 1 is sent. Any idea why it seemed like it is flipped? Thank you
This apparently is normal behaviour for most ESP Cores from what I have found in data sheets and is very confusing.