🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    DigitalWrite

    Arduino
    4
    4
    3.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sleepyfatcat
      last edited by

      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

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        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

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 1
        • H
          holofloh
          last edited by

          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.

          1 Reply Last reply Reply Quote 1
          • ajb2k3A
            ajb2k3 @sleepyfatcat
            last edited by

            @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.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post