Hi guys I am using NODEMCU for turning on and off the led using a switch, nodemcu is resetting it automatically thus disabling itself to get into the loop. How to solve this issue?
Code:
#include <ESP8266WiFi.h>
#define ledPin 6 // choose the pin for the LED
#define switchPin 7 // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup(){
Serial.begin(115200);
Serial.println("begin");
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(switchPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(switchPin);
Serial.println(val);
if (val == 0)
{
digitalWrite(ledPin, LOW);
Serial.println("Low");
delay(200);
} else {
digitalWrite(ledPin, HIGH);
Serial.println("High");
delay(200);
}
}
Error on Serial Monitor:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vac02aff5
~ld
begin
Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).
➜ please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's barely readable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)
Are you using the following NodeMCU Board (Fig-1)? If yes, then where are the GPIO 6 and 7. If not using the board of Fig-1, please post the picture of your board.