Catégories
Liens
/* * Wemos Mini + Blynk app > 2 LEDS and 2 Servos * * Mapping Wemos Actuators * D7 LED Green * D8 LED Red * D1 Servo1 * D2 Servo2 * GND GND * 5V (extern for servos) * * On Blynk app * Button V1 (virtual) : 0-1 > LED1 * Slider V2 (virtual) : 0-255 > LED2 * Slider V3 (virtual) : 0-180 > servo1, servo2 */ // Include Blynkapp libraries #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // Include Servo #include <Servo.h> // Blynk app auth key (get it from Blynk app on your mobile phone) char auth[] = "********************"; // Wiki network (from a mobile phone) / Partage de connexion ou Hotspot Wi-Fi char ssid[] = "*********";// Your WiFi credentials. char pass[] = "*********"; // Password. #define LED1 D8 #define LED2 D7 Servo servo1, servo2; int val_v3 = 0; // Store value from Virtual V3 Slider void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); servo1.attach(D1); servo2.attach(D2); Blynk.begin(auth, ssid, pass); } void loop() { Blynk.run(); } // Button 0-1 BLYNK_WRITE(V1) { digitalWrite(LED1,param.asInt()); } // Slider 0-255 BLYNK_WRITE(V2) { analogWrite(LED2,param.asInt()); } // Slider 0-180 BLYNK_WRITE(V3) { val_v3 = param.asInt(); servo1.write(val_v3); servo2.write(180-val_v3); }