portfolio

Writing Your First Program

Course Content
Session 1: Introduction to ESP32
Objective: Get familiar with the ESP32 microcontroller and set up the development environment.
0/5
Session 2: Interfacing with Sensors and Displays
Learn how to connect a DHT22 sensor and an OLED display to the ESP32.
0/4
Session 4: Programming the OLED Display
Objective: Write code to display information on the OLED display.
0/4
Session 5: Integrating Sensor Data with OLED Display
Objective: Combine sensor readings with OLED display functionality.
0/1
Session 6: Setup WIFI Capability
0/1
Session 7: Adding a Webserver
0/1
Session 8: Wrap-up
0/1
ESP32 Basics
About Lesson

A. The Blink LED Example

The classic “Blink” program is a simple way to verify that everything is working correctly.

**1. Understanding the Code

Here’s a simple example code that blinks an LED connected to GPIO 2 on the ESP32:

cpp
void setup() {
  pinMode(2, OUTPUT); // Initialize digital pin 2 as an output.
}

void loop() {
  digitalWrite(2, HIGH); // Turn the LED on.
  delay(1000);           // Wait for a second.
  digitalWrite(2, LOW);  // Turn the LED off.
  delay(1000);           // Wait for a second.
}
  • setup(): Initializes the pin as an output.
  • loop(): Repeats the process of turning the LED on and off with a delay.

**2. Uploading the Code

  • Select the ESP32 board from Tools → Board.
  • Choose the correct COM port from Tools → Port.
  • Click the upload button and wait for the code to compile and upload.

B. Observing the Results

The LED on the ESP32 board should blink on and off, indicating that your program is running correctly.

C. Troubleshooting

  • Common issues (e.g., COM port not found, driver issues).

Interactive Element:

  • Code Editor: Try modifying the delay time in the provided code snippet and see how it affects the LED blink rate.