ESP32 Tutorial 3/55 - Resistor, LED, Breadboard Project: Hello LED -ESP32 IoT Learning kit

ESP32 Tutorial 3/55 - Resistor, LED, Breadboard Project: Hello LED -ESP32 IoT Learning kit

This tutorial guides you through your first ESP32 project: blinking an LED! This seemingly simple project is foundational to understanding hardware interfacing and programming microcontrollers. It lays the groundwork for more complex IoT projects. Here are some ideas to expand on this project:

  • Create a simple night light with adjustable brightness.
  • Build a visual indicator for a sensor reading (e.g., temperature, humidity).
  • Design a basic alarm system using an LED as an indicator.
  • Integrate the LED into a larger IoT project, such as a smart home system.

Hardware/Components

To complete this project, you will need the following components (in video at 00:35):

  • ESP32 microcontroller (e.g., from a SunFounder ESP32 IoT Learning Kit).
  • LED (Light Emitting Diode).
  • 220-ohm resistor.
  • Breadboard.
  • Jumper wires.

The ESP32, with its built-in Wi-Fi and Bluetooth, offers extensive capabilities beyond a standard Arduino Uno (in video at 00:47).

Wiring Guide

The wiring is straightforward. (in video at 20:34) Connect the longer leg (anode) of the LED to the positive rail of the breadboard. Connect the shorter leg (cathode) of the LED to one end of the 220-ohm resistor. Connect the other end of the resistor to a digital pin on your ESP32 (pin 26 in this example). Finally, connect the ground wire from the breadboard to the GND pin of your ESP32. A voltage divider is necessary to prevent damage to the LED. The resistor limits the current flowing through the LED, ensuring it doesn't exceed its maximum rating (in video at 07:27).

%%WIRING%%

Code Explanation

The Arduino code is quite simple. The key parts are:


//the number of the LED pin
const int ledPin = 9; // User-defined pin for the LED (in video at 25:37)

void setup() {
  pinMode(ledPin, OUTPUT); // Set the LED pin as an output (in video at 26:23)
}

void loop() {
  digitalWrite(ledPin, HIGH); // Turn the LED on (in video at 27:08)
  delay(500); // Wait for half a second (in video at 28:30)
  digitalWrite(ledPin, LOW); // Turn the LED off (in video at 28:30)
  delay(500); // Wait for half a second (in video at 28:30)
}

The ledPin constant defines which digital pin the LED is connected to. You can change this value to match your wiring. The setup() function initializes the pin mode. The loop() function continuously toggles the LED on and off with a 500ms delay. You can adjust the delay values (in milliseconds) to change the blink rate (in video at 31:56).

Live Project/Demonstration

The video demonstrates the complete process, from wiring to code upload and execution (in video at 29:16). The instructor shows how to check the connection using the 3.3V pin, ensuring the wiring is correct before connecting to the designated ESP32 pin (in video at 21:39). The video also highlights the use of the Arduino IDE, showing how to select the board and upload the code (in video at 30:01).

Chapters

  • [00:00] Introduction and Project Overview
  • [02:02] Understanding Resistors
  • [05:48] Understanding LEDs
  • [08:59] Introduction to Breadboards
  • [18:34] Breadboard Connections and Power Rails
  • [20:34] Wiring the LED Circuit
  • [22:17] Arduino Code and Explanation
  • [29:16] Uploading the Code and Testing
789-ESP32 Tutorial 3/55 - Hello LED with Arduino
Idioma: C++
¡Copiado!

Recursos y referencias

Archivos📁

No hay archivos disponibles.