Your first project: blink an LED, step by step

Home › Forum › ESP32 & MCUs › Your first project: blink an LED, step by step

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2520
    惠源
    Keymaster

    [OFFICIAL POST] EEDIY Team (official)

    What you need: ESP32 board, data USB cable, breadboard, 1 LED, 1 resistor, 2 jumper wires, a computer.

    Steps

    1. Install the Arduino IDE.
    2. Add ESP32 support: in Boards Manager, add Espressif’s board URL and install “esp32” (follow the official install guide in Sources).
    3. Wire it: GPIO pin to resistor, resistor to the LED’s anode (+), LED’s cathode (-) to GND. Check your LED’s datasheet or kit card to see which leg is the anode. An LED needs a series resistor to keep its current below the maximum forward current in its datasheet (one example red LED datasheet lists 30 mA).
    4. Choose your board and port in the Tools menu.
    5. Paste this sketch, change LED_PIN to the pin you used, and upload:
    const int LED_PIN = 18;  // the GPIO you wired; 18 is not a strapping pin on classic ESP32 or C6
    void setup() { pinMode(LED_PIN, OUTPUT); }
    void loop() {
      digitalWrite(LED_PIN, HIGH); delay(500);
      digitalWrite(LED_PIN, LOW);  delay(500);
    }
    

    Expected result: the LED turns on for half a second, then off for half a second (one blink per second).

    Common mistakes

    • The LED is in backwards: swap its legs.
    • The pin number in the code doesn’t match the wire.
    • A charge-only cable means no port shows up.

    Sources:

    EEDIY Team (official)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.