fork download
  1. /* ใช้สำหรับเพื่อการศึกษาเท่านั่น
  2.   ห้ามใช้ในเชิงพาณิช
  3.   อุดหนุนอุปกรณ์ของเราได้ที่ www.ec-bot.com
  4. */
  5. #define BLYNK_PRINT Serial
  6. #include <ESP8266WiFi.h>
  7. #include <BlynkSimpleEsp8266.h>
  8. #include <Servo.h>
  9. Servo myservo;
  10. char auth[] = "xxx"; // Token App Blynk
  11. char ssid[] = "xxx"; // ชื่อ Wi-Fi
  12. char pass[] = "xxx"; // รหัส Wi-Fi
  13. int Step = 0;
  14. int State = 0;
  15.  
  16. BLYNK_WRITE(V0)
  17. {
  18. if (param.asInt() == 1) {
  19. Step = 1;
  20. } else {
  21. Step = 0;
  22. }
  23. }
  24.  
  25. void setup()
  26. {
  27. myservo.attach(D4);
  28. myservo.write(0);
  29. Serial.begin(9600);
  30. Blynk.begin(auth, ssid, pass); // เชื่อมต่อ auth , ssis , pass
  31. }
  32.  
  33.  
  34. {
  35. Blynk.run();
  36. Serial.println(State);
  37. if (Step == 0 && State == 0) {
  38. myservo.write(0);
  39. } else if (Step == 1 && State == 0) {
  40. State = 1;
  41. } else if (State == 1) {
  42. myservo.write(80);
  43. delay(500);
  44. myservo.write(0);
  45. delay(5000);
  46. State = 0;
  47. }
  48. }
Success #stdin #stdout 0.04s 25372KB
stdin
Standard input is empty
stdout
/* ใช้สำหรับเพื่อการศึกษาเท่านั่น
    ห้ามใช้ในเชิงพาณิช
    อุดหนุนอุปกรณ์ของเราได้ที่ www.ec-bot.com
*/
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>
Servo myservo;
char auth[] = "xxx"; // Token App Blynk
char ssid[] = "xxx"; // ชื่อ Wi-Fi
char pass[] = "xxx"; // รหัส Wi-Fi
int Step = 0;
int State = 0;

BLYNK_WRITE(V0)
{
  if (param.asInt() == 1) {
    Step = 1;
  } else {
    Step = 0;
  }
}

void setup()
{
  myservo.attach(D4);
  myservo.write(0);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass); // เชื่อมต่อ auth , ssis , pass
}


{
  Blynk.run();
  Serial.println(State);
  if (Step == 0 && State == 0) {
    myservo.write(0);
  } else if  (Step == 1 && State == 0) {
    State = 1;
  } else if (State == 1) {
    myservo.write(80);
    delay(500);
    myservo.write(0);
    delay(5000);
    State = 0;
  }
}