<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mohamed Ahmed</title>
    <description>The latest articles on Forem by Mohamed Ahmed (@mohamed_ahmed_dev).</description>
    <link>https://forem.com/mohamed_ahmed_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3536881%2F67a007f3-7a03-49c6-9971-cfc168defaca.png</url>
      <title>Forem: Mohamed Ahmed</title>
      <link>https://forem.com/mohamed_ahmed_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohamed_ahmed_dev"/>
    <language>en</language>
    <item>
      <title>🔐 Control a Solenoid Lock with Arduino Mega (Using a Relay &amp; Push Button)</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Wed, 19 Nov 2025 09:11:53 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/control-a-solenoid-lock-with-arduino-mega-using-a-relay-push-button-3jop</link>
      <guid>https://forem.com/mohamed_ahmed_dev/control-a-solenoid-lock-with-arduino-mega-using-a-relay-push-button-3jop</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Welcome back, makers! 👋&lt;br&gt;
If you enjoyed building Wi-Fi-controlled LEDs, let’s take things a step further into the world of physical security. Today, we’re working with solenoid locks — the same mechanism used in lockers, cabinets, and access-control systems.&lt;/p&gt;

&lt;p&gt;In this project, you’ll learn how to lock and unlock a solenoid lock using:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;1. Arduino Mega&lt;/li&gt;
&lt;li&gt;2. A relay module&lt;/li&gt;
&lt;li&gt;3. 12V power supply&lt;/li&gt;
&lt;li&gt;4. Simple push button&lt;/li&gt;
&lt;li&gt;Breadboard&lt;/li&gt;
&lt;li&gt;Jumper wires(male to male and male to female)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;By the end, you’ll push a button → the solenoid will pull → the lock will OPEN.&lt;/li&gt;
&lt;li&gt;Push the button again → the solenoid releases → the lock goes back to LOCKED.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s dive in!&lt;/p&gt;
&lt;h3&gt;
  
  
  🧰 What You’ll Need
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Image&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Arduino Mega&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fot67rj8go1o6lfv60sly.webp" alt="Arduino Mega" width="800" height="800"&gt;&lt;/td&gt;
&lt;td&gt;Microcontroller to read button and control relay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12V Solenoid Lock&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41fuqj4d5on4sb7416gd.jpg" alt="Solenoid Lock" width="480" height="360"&gt;&lt;/td&gt;
&lt;td&gt;The physical locking mechanism&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relay Module (5V Control)&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1326nzlwgm95sdwfalm3.jpg" alt="Relay Module" width="500" height="500"&gt;&lt;/td&gt;
&lt;td&gt;Acts as a switch to send 12V to the solenoid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12V Power Adapter&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4ehzdxk628wcuei0tim.jpg" alt="12V Adapter" width="320" height="320"&gt;&lt;/td&gt;
&lt;td&gt;Powers the solenoid and Arduino&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Push Button&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3a91js6rf79ksep4u03.png" alt="Push Button" width="800" height="800"&gt;&lt;/td&gt;
&lt;td&gt;Triggers lock/unlock&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Breadboard &amp;amp; Jumper Wires&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcTJSc2n0DoX8PFuA1LG6GKG9V81mOPCae8FFA%26s" alt="Breadboard" width="225" height="225"&gt;&lt;/td&gt;
&lt;td&gt;For easy wiring&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  ⚡ Step 1: Wiring Diagram
&lt;/h3&gt;

&lt;p&gt;Here’s the wiring logic broken down clearly:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔘 Button to Arduino&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Arduino Pin&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Button Lead 1&lt;/td&gt;
&lt;td&gt;D2&lt;/td&gt;
&lt;td&gt;Reads button press&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Button Lead 2&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Completes button circuit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;🔁 Relay Module to Arduino&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Arduino Pin&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;td&gt;5V&lt;/td&gt;
&lt;td&gt;Powers relay coil&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN&lt;/td&gt;
&lt;td&gt;D8&lt;/td&gt;
&lt;td&gt;Arduino signal to toggle solenoid&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;🔌 Power + Solenoid Connection&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Connected To&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;12V Adapter&lt;/td&gt;
&lt;td&gt;Arduino Barrel Jack&lt;/td&gt;
&lt;td&gt;Powers Arduino and relay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12V Adapter + (Positive)&lt;/td&gt;
&lt;td&gt;Relay COM&lt;/td&gt;
&lt;td&gt;12V source for switching&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Solenoid Red Wire&lt;/td&gt;
&lt;td&gt;Relay NO&lt;/td&gt;
&lt;td&gt;Receives switched 12V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Solenoid Blue Wire&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Completes 12V circuit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;💡 We use the relay because the solenoid draws more current than Arduino can provide.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 Step 2: Write the Code
&lt;/h3&gt;

&lt;p&gt;Open your Arduino IDE and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define the pins used
const int buttonPin = 2;   
const int relayPin = 8;    

bool isLocked = true; 

void setup() {
  pinMode(relayPin, OUTPUT); 
  // Use INPUT_PULLUP for simpler button wiring
  pinMode(buttonPin, INPUT_PULLUP); 

  // SET INITIAL STATE: LOCK the door (Solenoid needs POWER ON to be locked)
  digitalWrite(relayPin, HIGH); 
}

void loop() {
  // Read the button state (it reads LOW when pressed)
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) { // Button pressed
    delay(50); // Debounce
    if (digitalRead(buttonPin) == LOW) {
      isLocked = !isLocked; // Toggle the state

      if (isLocked) {
        // LOCK: Solenoid ON (Power applied)
        digitalWrite(relayPin, HIGH); 
      } else {
        // UNLOCK: Solenoid OFF (Power removed)
        digitalWrite(relayPin, LOW); 
      }

      // Wait for the button to be released 
      while(digitalRead(buttonPin) == LOW){
        // Do nothing 
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🧠 Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The button uses INPUT_PULLUP, meaning:

&lt;ul&gt;
&lt;li&gt;Released → HIGH&lt;/li&gt;
&lt;li&gt;Pressed → LOW&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;When pressed, Arduino sets relay HIGH → relay sends 12V to solenoid → it unlocks.&lt;/li&gt;

&lt;li&gt;When pushed again → relay turns OFF → the solenoid locks again.&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  🧪 Step 3: Test the Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Power the Arduino using your 12V adapter.&lt;/li&gt;
&lt;li&gt;Open the Serial Monitor — you should see "Solenoid Lock System Ready".&lt;/li&gt;
&lt;li&gt;Press the button:

&lt;ul&gt;
&lt;li&gt;You should hear a click from the relay.&lt;/li&gt;
&lt;li&gt;Solenoid retracts (unlock).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Press the button again:

&lt;ul&gt;
&lt;li&gt;Solenoid extends (lock).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;🔐⚡ If everything is wired correctly — congratulations, you’ve built your own electromechanical locking system!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft549i3uouuvh1qoynr65.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft549i3uouuvh1qoynr65.jpg" alt=" " width="720" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>beginners</category>
      <category>iot</category>
      <category>programming</category>
    </item>
    <item>
      <title>🌐 Control Your LED from a Web Server Using ESP32 Introduction</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Fri, 24 Oct 2025 14:00:00 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/control-your-led-from-a-web-server-using-esp32-introduction-189b</link>
      <guid>https://forem.com/mohamed_ahmed_dev/control-your-led-from-a-web-server-using-esp32-introduction-189b</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Welcome back, makers! 👋&lt;br&gt;
So far, we’ve learned how to blink an LED, connect an external one, and control it using a button. Now, it’s time to make things even more exciting — we’ll control the LED using a simple web interface hosted directly on your ESP32!&lt;/p&gt;

&lt;p&gt;By the end of this tutorial, you’ll be able to open a webpage on your phone or computer and turn the LED ON or OFF wirelessly.&lt;/p&gt;
&lt;h3&gt;
  
  
  🧰 What You’ll Need
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;- ESP32 development board (e.g., ESP32 DevKit C)&lt;/li&gt;
&lt;li&gt;- 1 × LED (any color)&lt;/li&gt;
&lt;li&gt;- 1 × 220 Ω resistor&lt;/li&gt;
&lt;li&gt;- Breadboard and jumper wires&lt;/li&gt;
&lt;li&gt;- Arduino IDE installed and configured&lt;/li&gt;
&lt;li&gt;- A Wi-Fi network (SSID and password)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  ⚡ Step 1: Breadboard/Circuit Setup
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;ESP32 Pin&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LED (anode – long leg)&lt;/td&gt;
&lt;td&gt;GPIO 4&lt;/td&gt;
&lt;td&gt;Digital output pin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LED (cathode – short leg)&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resistor (220 Ω)&lt;/td&gt;
&lt;td&gt;In series with LED&lt;/td&gt;
&lt;td&gt;Limits current&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;💡 Use the same wiring as in the previous post — we’ll just control it differently this time.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 Step 2: Write the Code
&lt;/h3&gt;

&lt;p&gt;Open your Arduino IDE and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;WiFi.h&amp;gt;

// Replace with your network credentials
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";

WiFiServer server(80);  // Port 80 for HTTP
int ledPin = 4;         // GPIO 4 for LED

void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  Serial.println("Connecting to WiFi...");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  // Your web server address

  server.begin();
}

void loop() {
  WiFiClient client = server.available();   // Listen for incoming clients

  if (client) {
    Serial.println("New Client Connected.");
    String request = client.readStringUntil('\r');
    Serial.println(request);
    client.flush();

    // Control LED
    if (request.indexOf("/LED=ON") != -1) {
      digitalWrite(ledPin, HIGH);
    } else if (request.indexOf("/LED=OFF") != -1) {
      digitalWrite(ledPin, LOW);
    }

    // Build Web Page
    String html = "&amp;lt;!DOCTYPE html&amp;gt;&amp;lt;html&amp;gt;";
    html += "&amp;lt;head&amp;gt;&amp;lt;meta name='viewport' content='width=device-width, initial-scale=1'&amp;gt;";
    html += "&amp;lt;title&amp;gt;ESP32 LED Control&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;";
    html += "&amp;lt;body style='text-align:center; font-family:sans-serif;'&amp;gt;";
    html += "&amp;lt;h2&amp;gt;ESP32 Web LED Controller 💡&amp;lt;/h2&amp;gt;";
    html += "&amp;lt;p&amp;gt;&amp;lt;a href='/LED=ON'&amp;gt;&amp;lt;button style='padding:10px 20px; background:green; color:white; border:none;'&amp;gt;TURN ON&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;";
    html += "&amp;lt;p&amp;gt;&amp;lt;a href='/LED=OFF'&amp;gt;&amp;lt;button style='padding:10px 20px; background:red; color:white; border:none;'&amp;gt;TURN OFF&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;";
    html += "&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;";

    client.println("HTTP/1.1 200 OK");
    client.println("Content-type:text/html");
    client.println();
    client.println(html);
    client.stop();
    Serial.println("Client disconnected.");
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🧠 How It Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The ESP32 connects to your Wi-Fi network using your SSID and password.&lt;/li&gt;
&lt;li&gt;It starts a simple web server that listens for incoming connections on port 80.&lt;/li&gt;
&lt;li&gt;When you open the ESP32’s IP address in your browser, it serves a web page with two buttons.&lt;/li&gt;
&lt;li&gt;Clicking TURN ON or TURN OFF sends a request (/LED=ON or /LED=OFF) that toggles the LED.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🖥️ Step 3: Upload and Test
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;- Connect your ESP32 to your computer.&lt;/li&gt;
&lt;li&gt;- Select your board and port in the Arduino IDE.&lt;/li&gt;
&lt;li&gt;- Replace YOUR_WIFI_NAME and YOUR_WIFI_PASSWORD with your Wi-Fi credentials.&lt;/li&gt;
&lt;li&gt;- Click Upload.&lt;/li&gt;
&lt;li&gt;- Open Serial Monitor (115200 baud).&lt;/li&gt;
&lt;li&gt;- After connecting, note the IP address displayed (e.g., 192.168.0.105).
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funahomsj6g73emzz46rx.png" alt="Your IDE should look like this" width="800" height="407"&gt;
&lt;/li&gt;
&lt;li&gt;- Type that IP address in your browser — you’ll see your control page!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb24n0kq3po8r1ec4rhl7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb24n0kq3po8r1ec4rhl7.png" alt="Your web page should look like this" width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the buttons — your LED should respond instantly! ⚡&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzd2stdfgxj98ogswt20g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzd2stdfgxj98ogswt20g.jpg" alt="Your ESP321 should look like this" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
⚡ Troubleshooting&lt;br&gt;
1.No IP address shown?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Double-check your Wi-Fi name and password.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2.Page not loading?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure your computer/phone is on the same Wi-Fi network as your ESP32.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.LED not turning on?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify your wiring and GPIO pin number in the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🎯 What’s Next&lt;br&gt;
You’ve now built your first IoT web interface! 🌍&lt;br&gt;
✅ Connected ESP32 to Wi-Fi&lt;br&gt;
✅ Hosted a mini web server&lt;br&gt;
✅ Controlled hardware from a browser&lt;/p&gt;

&lt;p&gt;In the next post, we’ll go further — read sensor data (like temperature or light) and display it on your web dashboard in real time. 📊&lt;/p&gt;

&lt;p&gt;💬 Your Turn&lt;br&gt;
Did you manage to control your LED from your browser? 💡&lt;br&gt;
Share your setup, screenshots, or questions in the comments — let’s keep learning and building together! 🙌&lt;/p&gt;

</description>
      <category>iot</category>
      <category>esp32</category>
      <category>webserver</category>
      <category>led</category>
    </item>
    <item>
      <title>🕹️ Control an LED with a Button Using ESP32 and Arduino IDE Introduction</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Fri, 17 Oct 2025 14:00:00 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/control-an-led-with-a-button-using-esp32-and-arduino-ide-introduction-2neg</link>
      <guid>https://forem.com/mohamed_ahmed_dev/control-an-led-with-a-button-using-esp32-and-arduino-ide-introduction-2neg</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Welcome back, makers! 👋&lt;br&gt;
In the &lt;a href="https://dev.to/mohamed_ahmed_dev/controlling-an-external-led-with-esp32-and-arduino-ide-1n3o"&gt;previous post&lt;/a&gt;, we connected and controlled an external LED using the ESP32.&lt;/p&gt;

&lt;p&gt;Now, let’s take it a step further — by using a push button to turn the LED on and off.&lt;br&gt;
This is a fundamental IoT concept: using input devices (like buttons or sensors) to control output devices (like LEDs or motors).&lt;/p&gt;
&lt;h3&gt;
  
  
  🧰 What You’ll Need
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;ESP32 development board (e.g., ESP32 DevKit C)&lt;/li&gt;
&lt;li&gt;1 × LED (any color)&lt;/li&gt;
&lt;li&gt;1 × 220 Ω resistor (for the LED)&lt;/li&gt;
&lt;li&gt;1 × Push button&lt;/li&gt;
&lt;li&gt;Breadboard&lt;/li&gt;
&lt;li&gt;Jumper wires&lt;/li&gt;
&lt;li&gt;USB cable connected to your computer&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  ⚙️ Step 1: Breadboard/circuit Connections
&lt;/h3&gt;

&lt;p&gt;Here’s how to wire everything:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;ESP32 Pin&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LED (long leg – anode)&lt;/td&gt;
&lt;td&gt;GPIO 4&lt;/td&gt;
&lt;td&gt;Digital output pin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LED (short leg – cathode)&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resistor (220 Ω)&lt;/td&gt;
&lt;td&gt;In series with LED&lt;/td&gt;
&lt;td&gt;Limits current to protect the LED&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Button&lt;/td&gt;
&lt;td&gt;GPIO 21&lt;/td&gt;
&lt;td&gt;Digital input pin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other side of Button&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Pulls the button LOW when pressed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;💡 Tip: We’ll use the ESP32’s internal pull-up resistor to keep things simple, so you don’t need an extra resistor for the button.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 Step 2: Write the Code
&lt;/h3&gt;

&lt;p&gt;Open the Arduino IDE and paste this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Control an LED with a button using ESP32
int ledPin = 4;      // LED connected to GPIO 4
int buttonPin = 21;  // Button connected to GPIO 15
int buttonState = 0; // Variable to store button state

void setup() {
  pinMode(ledPin, OUTPUT);        // Set LED pin as output
  pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
  Serial.begin(115200);
  Serial.println("Button Control Test Started");
}

void loop() {
  buttonState = digitalRead(buttonPin); // Read the button state

  if (buttonState == LOW) {  // Button pressed (active LOW)
    digitalWrite(ledPin, HIGH);
    Serial.println("Button Pressed - LED ON");
  } else {  // Button not pressed
    digitalWrite(ledPin, LOW);
    Serial.println("Button Released - LED OFF");
  }

  delay(100); // Small delay for stability
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🧠 Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;pinMode(buttonPin, INPUT_PULLUP) enables the internal resistor that keeps the button HIGH until pressed.&lt;/li&gt;
&lt;li&gt;When you press the button, the pin reads LOW.&lt;/li&gt;
&lt;li&gt;The LED turns ON when the button is pressed and OFF when released.&lt;/li&gt;
&lt;li&gt;The Serial Monitor displays real-time button states.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🖥️ Step 3: Upload and Test
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;- Connect your ESP32 to your computer.&lt;/li&gt;
&lt;li&gt;- Select the correct Board and Port.&lt;/li&gt;
&lt;li&gt;- Click Upload.&lt;/li&gt;
&lt;li&gt;- Open Tools → Serial Monitor and set the baud rate to 115200.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now press and release the button — you should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Button Pressed - LED ON
Button Released - LED OFF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd4ioft4tvt84vhxv3ivg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd4ioft4tvt84vhxv3ivg.jpg" alt="Your ESP32 should look like this" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
1.LED doesn’t turn on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your wiring (especially button → GPIO21 → GND).&lt;/li&gt;
&lt;li&gt;Make sure the LED’s anode (+) is connected to the correct GPIO pin.&lt;/li&gt;
&lt;li&gt;Verify resistor placement (in series with LED).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2.Serial Monitor not showing messages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure baud rate = 115200.&lt;/li&gt;
&lt;li&gt;Confirm you added Serial.begin(115200); in setup().&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🎯 What’s Next&lt;/p&gt;

&lt;p&gt;You’ve now learned how to:&lt;br&gt;
✅ Read digital input from a button&lt;br&gt;
✅ Control an LED based on input&lt;br&gt;
✅ Display data in the Serial Monitor&lt;/p&gt;

&lt;p&gt;In the next post, we’ll take it online 🌐 — you’ll learn how to control your LED using a simple web server hosted on the ESP32 itself!&lt;br&gt;
That means you’ll be able to turn your LED on and off right from your browser or phone — no button required. 💡📱&lt;/p&gt;

&lt;p&gt;💬 Your Turn!&lt;br&gt;
Did your LED respond to the button? 🕹️💡&lt;br&gt;
Share your results in the comments — I’d love to see your setup and help troubleshoot if needed.&lt;/p&gt;

</description>
      <category>iot</category>
      <category>buttons</category>
      <category>led</category>
      <category>esp32</category>
    </item>
    <item>
      <title>💡 Controlling an External LED with ESP32 and Arduino IDE</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Fri, 10 Oct 2025 14:00:00 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/controlling-an-external-led-with-esp32-and-arduino-ide-1n3o</link>
      <guid>https://forem.com/mohamed_ahmed_dev/controlling-an-external-led-with-esp32-and-arduino-ide-1n3o</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Welcome back, makers! 👋&lt;br&gt;
In the &lt;a href="https://dev.to/mohamed_ahmed_dev/uploading-your-code-with-arduino-ide-3k29"&gt;previous post&lt;/a&gt; we successfully uploaded our first program — the classic “Blink” — to make the built-in LED on the ESP32 blink.&lt;/p&gt;

&lt;p&gt;Now, we’ll take it a step further by connecting and controlling an external LED.&lt;br&gt;
This is your first step into hardware interaction — where your ESP32 begins to control real-world devices!&lt;/p&gt;
&lt;h3&gt;
  
  
  🧰 What You’ll Need
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;- ESP32 development board (e.g., ESP32 DevKit C)&lt;/li&gt;
&lt;li&gt;- 1 × LED (any color)&lt;/li&gt;
&lt;li&gt;- 1 × 220 Ω resistor&lt;/li&gt;
&lt;li&gt;- Breadboard&lt;/li&gt;
&lt;li&gt;- Jumper wires&lt;/li&gt;
&lt;li&gt;- USB cable connected to your computer&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  ⚙️ Step 1: Breadboard/circuit Connections
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;ESP32 pin&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LED (long leg – anode)&lt;/td&gt;
&lt;td&gt;GPIO 4&lt;/td&gt;
&lt;td&gt;Digital output pin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LED (short leg – cathode)&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resistor (220 Ω)&lt;/td&gt;
&lt;td&gt;In series with LED&lt;/td&gt;
&lt;td&gt;Limits current to protect LED&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can use GPIO 5, 13, or 14 — just make sure to update the code accordingly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡 Tip: You can use GPIO 5, 13, or 14 instead — just update the code accordingly.&lt;br&gt;
Always use a resistor in series with your LED to prevent burning it out!&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 Step 2: Write the Code
&lt;/h3&gt;

&lt;p&gt;In the Arduino IDE, open a new sketch and paste this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Control an external LED using ESP32
int ledPin = 4; // The GPIO pin connected to the LED

void setup() {
  pinMode(ledPin, OUTPUT); // Set the LED pin as output
  Serial.begin(115200);      // Start the Serial Monitor
  Serial.println("External LED Test Started");
}

void loop() {
  digitalWrite(ledPin, HIGH); // Turn LED on
  Serial.println("LED is ON");
  delay(1000);                // Wait 1 second

  digitalWrite(ledPin, LOW);  // Turn LED off
  Serial.println("LED is OFF");
  delay(1000);                // Wait 1 second
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧠 Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pinMode(ledPin, OUTPUT) tells the ESP32 that GPIO 4 will send signals.&lt;/li&gt;
&lt;li&gt;digitalWrite(ledPin, HIGH/LOW) turns the LED on and off.&lt;/li&gt;
&lt;li&gt;The Serial Monitor prints real-time messages so you can see what the board is doing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🖥️ Step 3: Upload and Monitor
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Connect your ESP32 to your computer.&lt;/li&gt;
&lt;li&gt;Select the correct board and port (as before).&lt;/li&gt;
&lt;li&gt;Click Upload.&lt;/li&gt;
&lt;li&gt;After uploading, open Tools → Serial Monitor.&lt;/li&gt;
&lt;li&gt;Set the baud rate to 115200.
You should see messages like:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb30lzssfm6cbvy7x2euv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb30lzssfm6cbvy7x2euv.png" alt="Your IDE should look like this" width="800" height="179"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Your external LED should blink in sync! ✨&lt;br&gt;
_&lt;/em&gt;💡 Tip: On some boards, you may need to hold the BOOT button while uploading the code._&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flu0hf218vjpde6hublsd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flu0hf218vjpde6hublsd.jpg" alt="Your IDE should look like this" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚡ Troubleshooting
&lt;/h3&gt;

&lt;p&gt;1.LED not lighting up?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your wiring (make sure anode and cathode aren’t reversed).&lt;/li&gt;
&lt;li&gt;Try a different GPIO pin and update the code.&lt;/li&gt;
&lt;li&gt;Verify that your resistor is not too large (220 Ω–330 Ω works best).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2.No Serial Output?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure you opened the Serial Monitor at 115200 baud.&lt;/li&gt;
&lt;li&gt;Make sure the code includes Serial.begin(115200);.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🎯 What’s Next&lt;br&gt;
✅ You’ve now controlled an external LED with your ESP32!&lt;br&gt;
In the next post, we’ll add a button so you can turn the LED on and off manually. 🕹️&lt;/p&gt;

&lt;p&gt;Get ready to make your first interactive circuit!&lt;/p&gt;

&lt;h3&gt;
  
  
  💬 Your Turn!
&lt;/h3&gt;

&lt;p&gt;Did your external LED blink? 🔴💡&lt;br&gt;
Share your success (or any issues you faced) in the comments — I’d love to see your first working circuit!&lt;/p&gt;

</description>
      <category>iot</category>
      <category>esp32</category>
      <category>arduinoide</category>
    </item>
    <item>
      <title>🚀 Uploading Your Code with Arduino IDE</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Sun, 05 Oct 2025 16:09:46 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/uploading-your-code-with-arduino-ide-3k29</link>
      <guid>https://forem.com/mohamed_ahmed_dev/uploading-your-code-with-arduino-ide-3k29</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Welcome back to our IoT journey! 👋&lt;br&gt;
In the previous post&lt;br&gt;
, we installed the Arduino IDE and configured it to recognize our ESP32 board.&lt;/p&gt;

&lt;p&gt;Now, it’s time to bring our board to life by uploading our very first program — the classic “Blink”. This small project will make the onboard LED on your ESP32 blink at regular intervals — a simple but exciting sign that everything is working!&lt;/p&gt;
&lt;h3&gt;
  
  
  🧰 What You’ll Need
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your ESP32 development board (e.g., ESP32 DevKit C)&lt;/li&gt;
&lt;li&gt;A USB cable (connected to your computer)&lt;/li&gt;
&lt;li&gt;The Arduino IDE (already configured for ESP32)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  ⚡ &lt;strong&gt;Step 1&lt;/strong&gt;: Open the Arduino IDE
&lt;/h3&gt;

&lt;p&gt;Launch the Arduino IDE on your computer.&lt;br&gt;
Make sure your ESP32 is connected to your PC via USB.&lt;/p&gt;
&lt;h3&gt;
  
  
  🧩 &lt;strong&gt;Step 2&lt;/strong&gt;: Select the Correct Board and Port
&lt;/h3&gt;

&lt;p&gt;Before writing any code, confirm that you’ve selected your ESP32 board and port correctly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to Tools → Board → ESP32 Arduino → ESP32 Dev Module&lt;/li&gt;
&lt;li&gt;Go to Tools → Port → select the one that says something like COM7&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_💡 If no port is visible, you may need to install the USB driver for your board (CH340 or CP210x depending on your model). You can check the chip model next to your USB port.&lt;br&gt;
_&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 &lt;strong&gt;Step 3&lt;/strong&gt;: Write the Blink Code
&lt;/h3&gt;

&lt;p&gt;In your Arduino IDE, copy and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The classic Blink program for ESP32
int ledPin = 2; // Built-in LED on most ESP32 boards is on GPIO 2

void setup() {
  pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
}

void loop() {
  digitalWrite(ledPin, HIGH); // Turn the LED on
  delay(1000);                // Wait 1 second
  digitalWrite(ledPin, LOW);  // Turn the LED off
  delay(1000);                // Wait 1 second
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;setup() runs once when your board starts.&lt;/li&gt;
&lt;li&gt;loop() runs continuously, making the LED turn on and off.&lt;/li&gt;
&lt;li&gt;delay(1000) means 1000 milliseconds (1 second).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;⚠️ If the upload fails, try holding the BOOT button on your ESP32 while uploading.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ⬆️ &lt;strong&gt;Step 4&lt;/strong&gt;: Upload the Code
&lt;/h3&gt;

&lt;p&gt;Now the fun part! 🎉&lt;br&gt;
Click the Upload button (the right-pointing arrow in the toolbar).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlzssgthd0uf17e9x4jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlzssgthd0uf17e9x4jp.png" alt="Your IDE should look like this:" width="800" height="62"&gt;&lt;/a&gt;&lt;br&gt;
You should see messages like “Compiling…” and “Uploading…” at the bottom.&lt;br&gt;
When it finishes, the onboard LED should start blinking once per second.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwrjpcyh8l2l6kdz8dsu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwrjpcyh8l2l6kdz8dsu.gif" alt="ESP32 should look like this" width="400" height="711"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;LED not blinking Some boards use different pins for the built-in LED. Try changing int ledPin = 2; to int ledPin = 5; or int ledPin = 13;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡 If the LED isn’t blinking, some boards use different pins for the built-in LED. Try changing int ledPin = 2; to int ledPin = 5; or int ledPin = 13;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎯 What’s Next&lt;/strong&gt;&lt;br&gt;
In the next post, we’ll take things a step further — moving from the built-in LED to controlling an external LED using wires, resistors, and ESP32 pins — all while monitoring outputs through the Serial Monitor.&lt;/p&gt;

&lt;p&gt;Until then — happy tinkering! 🔧✨&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Did your LED blink? *&lt;/em&gt;😄&lt;br&gt;
Share your success (or any errors you faced) in the comments — I’d love to help you troubleshoot and celebrate your first ESP32 project!&lt;/p&gt;

</description>
      <category>iot</category>
      <category>esp32</category>
      <category>arduino</category>
      <category>embedded</category>
    </item>
    <item>
      <title>Getting Started with IoT: Your First Steps with Arduino IDE and ESP32</title>
      <dc:creator>Mohamed Ahmed</dc:creator>
      <pubDate>Tue, 30 Sep 2025 16:36:28 +0000</pubDate>
      <link>https://forem.com/mohamed_ahmed_dev/getting-started-with-iot-your-first-steps-with-arduino-ide-and-esp32-5afh</link>
      <guid>https://forem.com/mohamed_ahmed_dev/getting-started-with-iot-your-first-steps-with-arduino-ide-and-esp32-5afh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;👋 Hello, world! I’m starting this blog to share my journey into the Internet of Things (IoT) using the ESP32 microcontroller. Whether you’re a hobbyist, student, or just curious, you can follow along as we go from zero to working IoT projects—starting with setting up the Arduino IDE.d.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You'll Need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A computer&lt;/li&gt;
&lt;li&gt;An ESP32 development board (like the ESP32 DevKit C)&lt;/li&gt;
&lt;li&gt;A USB cable (typically Micro-USB or USB-C, depending on your board)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;STEP 1&lt;/strong&gt;: Installing the Arduino IDE
&lt;/h3&gt;

&lt;p&gt;The Arduino IDE (Integrated Development Environment) is where we will write our code, compile it, and upload it to the ESP32.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download the IDE: Go to the official &lt;a href="https://www.arduino.cc/en/software/" rel="noopener noreferrer"&gt;Arduino Software page&lt;/a&gt;. Avoid the "Web Editor" for now; we want the IDE. Download the version for your operating system.&lt;/li&gt;
&lt;li&gt;Run the Installer:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Windows: Run the downloaded .exe file. It's recommended to let it install the necessary drivers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.Open the Arduino IDE: Once installed, open the application. You should see a clean, mostly empty window. This is your coding canvas!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi576j05ho2hsuujusvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi576j05ho2hsuujusvh.png" alt="Your IDE should look like this" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;STEP 2&lt;/strong&gt;: Configuring the IDE for ESP32
&lt;/h3&gt;

&lt;p&gt;The Arduino IDE doesn’t support ESP32 boards out of the box. To add support:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open Preferences: Go to File &amp;gt; Preferences.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdvqqpt2gu9avznmfwhx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdvqqpt2gu9avznmfwhx.png" alt="Your IDE should look like this" width="420" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the ESP32 Board Manager URL: In the "Additional Boards Manager URLs" field, paste the following URL:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7g1o9s0qu8cc3cy6veku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7g1o9s0qu8cc3cy6veku.png" alt="Your IDE should look like this" width="800" height="491"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;If you already have other URLs, separate them with a comma(,).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3.Open Boards Manager: Go to Tools &amp;gt; Board &amp;gt; Boards Manager&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnkr61mg1n9jpozvdluj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnkr61mg1n9jpozvdluj.png" alt="Your IDE should look like this" width="779" height="536"&gt;&lt;/a&gt;&lt;br&gt;
4.Install ESP32 Support: In the search bar, type "esp32". You should see an entry by "Espressif Systems". Click on it and press the "Install" button.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This will take a few minutes. Once it's done, you'll see "INSTALLED" next to the package.&lt;/em&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;STEP 3&lt;/strong&gt;: Selecting Your Board and Port
&lt;/h3&gt;

&lt;p&gt;Now that the software is installed, let's connect the hardware.&lt;/p&gt;

&lt;p&gt;Connect your ESP32: Plug your ESP32 board into your computer using the USB cable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Select Your Board&lt;/strong&gt;: Go to Tools &amp;gt; Board. You should now see a new section for "ESP32 Arduino". Scroll through it and select your specific board. If you're using a common &lt;em&gt;&lt;strong&gt;ESP32 Dev Module&lt;/strong&gt;&lt;/em&gt;, you can select that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmaa81y74zg2h54fjb6nl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmaa81y74zg2h54fjb6nl.png" alt="Your IDE should look like this" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Select the Port&lt;/strong&gt;: Go to Tools &amp;gt; Port.&lt;br&gt;
It will be something like COM3 or COM4.&lt;br&gt;
&lt;em&gt;but am using Port COM7&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsobo822v0kz8pye57s41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsobo822v0kz8pye57s41.png" alt="Your IDE should look like this" width="715" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If the port is grayed out or you don't see it, your computer might not have the correct drivers. A quick web search should lead you to the solution.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! &lt;/p&gt;

&lt;p&gt;What's Next?&lt;br&gt;
In the next post, we'll upload a simple code to verify everything is working. We'll use the classic "Blink". Get ready to make your hardware interact with you!&lt;/p&gt;

&lt;p&gt;What’s the first project you’d love to try with your ESP32? Drop your ideas in the comments—I’d love to hear them!&lt;/p&gt;

</description>
      <category>iot</category>
      <category>esp32</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
