Hello! I’m trying to get a LED widget on the app light up when i press a hardware button connecting a pin and 5v trough a resistor.It worked perfectly without blynk on an arduino Uno where a real LED lights up.But trying to blend blynk and the other code together makes the board keep restarting.Here’s the code:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "code code code";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID SSID SSID";
char pass[] = "pass pass pass";
// Select your pin with physical button
const int buttonPin = 8;
WidgetLED led3(V3);
SimpleTimer timer;
// V3 LED Widget represents the physical button state
void buttonLedWidget()
{
// Read button
if (digitalRead(buttonPin) == 1) led3.on();
else led3.off();
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
// Setup physical button pin (active low)
pinMode(buttonPin, INPUT);
timer.setInterval(500L, buttonLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
And this is the serial monitor output:
~?–$“Т¶Јя_CAZюы[243] Connecting to Xiaomi_EFB5
[3744] Connected to WiFi
[3744] IP: 192.168.31.138
[3744]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5087] Ready (ping: 0ms).
ь!m!„яж¦цю[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5096] Ready (ping: 0ms).
ьГЋ¦И1¤
сю[60] Connecting to Xiaomi_EFB5
[3061] Connected to WiFi
[3061] IP: 192.168.31.138
[3061]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5094] Ready (ping: 1ms).
ь
1И ЧЖэ1¦эя[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5086] Ready (ping: 1ms).
ьБ‡M¤„яжКUцю[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5089] Ready (ping: 1ms).
т!†M¤„я‹жхцю[60] Connecting to Xiaomi_EFB5
[3061] Connected to WiFi
[3061] IP: 192.168.31.138
[3061]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5098] Ready (ping: 1ms).
ь!m!dя‹Охя[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3562]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.3 on NodeMCU
Thank you in advance