TechKnowLab
Published © CC BY

Controlling LEDs using NodeMCU and PYTHON GUI

This project aims to simplify the process of interacting with hardware components, making it accessible for both beginners and experienced.

BeginnerFull instructions provided2 hours476

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
5 mm LED: Red
5 mm LED: Red
×4
Jumper wires (generic)
Jumper wires (generic)
×10
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
SparkFun Breadboard Power Supply 5V/3.3V
SparkFun Breadboard Power Supply 5V/3.3V
×1

Software apps and online services

Arduino IDE
Arduino IDE
Python IDE

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Schematics

Circuit - LED Control using GUI through NodeMCU

Circuit - LED Control using GUI through NodeMCU

Code

LED_NodeMCU_GUI.ino

Arduino
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

const char* ssid = "SSID";
const char* password = "Password";

ESP8266WebServer server(80);

int led1Pin = 12;
int led2Pin = 13;
int led3Pin = 14;
int led4Pin = 15;

void setup() {
  Serial.begin(115200);

  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  pinMode(led3Pin, OUTPUT);
  pinMode(led4Pin, OUTPUT);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");
  Serial.print("NodeMCU IP Address: ");
  Serial.println(WiFi.localIP());

  server.on("/led1", HTTP_GET, []() {
    digitalWrite(led1Pin, !digitalRead(led1Pin));
    server.send(200, "text/plain", "LED 1 toggled");
  });

  server.on("/led2", HTTP_GET, []() {
    digitalWrite(led2Pin, !digitalRead(led2Pin));
    server.send(200, "text/plain", "LED 2 toggled");
  });

  server.on("/led3", HTTP_GET, []() {
    digitalWrite(led3Pin, !digitalRead(led3Pin));
    server.send(200, "text/plain", "LED 3 toggled");
  });

  server.on("/led4", HTTP_GET, []() {
    digitalWrite(led4Pin, !digitalRead(led4Pin));
    server.send(200, "text/plain", "LED 4 toggled");
  });

  server.begin();
}

void loop() {
  server.handleClient();
}

Python GUI for NodeMCU LED Control Project

Credits

TechKnowLab

TechKnowLab

1 project • 0 followers
A 3D printing enthusiast and Arduino Lover

Comments