hrsajjad844
Published © MIT

Control an LED with Push-button Switch Using ESP8266

When the button switch is pressed, the LED light-up. when the switch is released, the LED goes out.

IntermediateShowcase (no instructions)2,991
Control an LED with Push-button Switch Using ESP8266

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Switch Actuator, Head for spring return push-button
Switch Actuator, Head for spring return push-button
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Story

Read more

Schematics

circuit diagram

Here is the project circuit.

Code

Code

C/C++
Here is the project code.
#include <ESP8266WiFi.h>

void setup() {
// put your setup code here, to run once:
pinMode(D0,INPUT);
pinMode(D1,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
int button=digitalRead(D0);
if(button==1){
digitalWrite(D1,LOW);
delay(100);
}
else{
digitalWrite(D1,HIGH);
delay(100);
}
}

Credits

hrsajjad844
1 project • 16 followers
Contact

Comments

Please log in or sign up to comment.