Mechatronics LAB
Published © GPL3+

ESP32 Fundamental Structure Arduino and MicroPython Sketch

In this section, you'll learn about the fundamental structure of an Arduino sketch and MicroPython script, which is essential for programmin

BeginnerProtip1 hour81
ESP32 Fundamental Structure Arduino and MicroPython Sketch

Things used in this project

Hardware components

ESP32 Development Board
×1
USB Cable
×1
LED
×1
Resistors
×1
Breadboard (optional)
×1
Jumper Wires
×1

Story

Read more

Schematics

ESP32 Fundamental Structure Arduino and MicroPython Sketch

Code

ESP32 Fundamental Structure Arduino and MicroPython Sketch

Arduino
// Define the GPIO pin connected to the LED
const int LED_PIN = 13; // Use GPIO 13 for onboard LED on most ESP32 boards
void setup()
{
pinMode(LED_PIN, OUTPUT); // Initialize the LED pin as an output
}
void loop()
{
digitalWrite(LED_PIN, HIGH);   // Turn the LED on (HIGH level)
delay(1000);                   // Wait for 1 second
digitalWrite(LED_PIN, LOW);    // Turn the LED off (LOW level)
delay(1000);                   // Wait for 1 second
}

Micropython

Python
from machine import Pin
import time
# Define the GPIO pin connected to the LED
LED_PIN = 13  # Use GPIO 13 for onboard LED on most ESP32 boards
# Initialize the LED pin
led = Pin(LED_PIN, Pin.OUT)
# Loop to blink the LED
while True:
led.on()    # Turn the LED on
time.sleep(1)  # Wait for 1 second
led.off()   # Turn the LED off
time.sleep(1)  # Wait for 1 second

Credits

Mechatronics LAB
75 projects • 47 followers
I am Sarful , I am a Mechatronics Engineer & also a teacher I am Interested in the evolution of technology in the automation industry .
Contact

Comments

Please log in or sign up to comment.