Advertisement
KRITSADA

NodeMCU and Code For Blynk

May 15th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <BlynkSimpleEsp8266.h>
  3. char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";  // On Sim
  4. int P0,P1;
  5. BLYNK_WRITE(V4){P0 = param.asInt();}
  6. BLYNK_WRITE(V1){P1 = param.asInt();analogWrite(14,P1);}
  7. void setup(){
  8.   Blynk.begin(auth,"user","password",IPAddress(159,89,39,112),8442);
  9.   pinMode(2,OUTPUT);pinMode(12,OUTPUT);pinMode(14,OUTPUT);
  10. }
  11. void loop(){
  12.   if(!digitalRead(13)){
  13.     Blynk.notify("You Press Key");
  14.   }
  15.   Blynk.run();
  16.   Blynk.virtualWrite(V0,analogRead(A0));
  17.   Blynk.virtualWrite(V5,P1);
  18.   if (P0){
  19.     digitalWrite(2,1);
  20.   }
  21.   else{
  22.     digitalWrite(2,0);
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement