Skip to content

Instantly share code, notes, and snippets.

@misternay
Created October 29, 2017 11:39
Show Gist options
  • Save misternay/78f259502dd4e94626363c349caa0832 to your computer and use it in GitHub Desktop.
Save misternay/78f259502dd4e94626363c349caa0832 to your computer and use it in GitHub Desktop.
BlynkLCD+BUTTON on Virtual PIN
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "--Token--";//นำโทเค็นในแอพมาใส่
char ssid[] = "--SSID--";//ชื้่อไวไฟ
char pass[] = "--PASSWORDWIFI--";//พาสเวิด
WidgetLCD lcd(V0);//เรียกใช้LCDโดยV0==VIRTURLPIN ที่เลือกไว้นะครับ
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
void sayHello() {
lcd.clear();
lcd.print(2, 0, "Hello World");//LCD
}
void sayGoodbye() {
lcd.clear();//ล้างLCD
lcd.print(2, 0, "GOOOD BYE!!!");//LCD
}
BLYNK_WRITE(V1)//นี่เป็นของBUTTON นะครับ
{
int stateBtn = param.asInt();//รับSTATEมา
if (stateBtn == 1)//ถ้ากดไปก็จะแสดงGoodBYe
{
sayGoodbye();
}else{
sayHello();//ถ้าไม่กดก็Helloไป
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment