Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // VIA CHAINE YOUTUBE EMAKERZ, https://www.youtube.com/channel/UCnNRQGz1SSgMGgFZzZRi8PA?view_as=subscriber
- #include <Arduino.h>
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- #include "fauxmoESP.h"
- #include <Servo.h>
- char auth[] = "code blink";
- char WIFI_SSID[] = "nom wifi";
- char WIFI_PASS[] = "mdp wifi";
- Servo servo;
- fauxmoESP fauxmo;
- BLYNK_WRITE(V1) {
- if( param.asInt() == 1 ){
- servo.write(0);
- delay(500);
- servo.write(70);
- }
- }
- BLYNK_WRITE(V2) {
- if( param.asInt() == 2 ){
- servo.write(70);
- }
- else if ( param.asInt() == 3 ){
- servo.write(0);
- }
- }
- void wifiSetup() {
- WiFi.mode(WIFI_STA);
- // Connect
- WiFi.begin(WIFI_SSID, WIFI_PASS);
- while (WiFi.status() != WL_CONNECTED) {
- delay(100);
- }
- }
- void setup() {
- servo.attach(0);
- Serial.begin(115200);
- Blynk.begin(auth, WIFI_SSID, WIFI_PASS);
- // Wifi
- wifiSetup();
- fauxmo.addDevice("emakerz");
- fauxmo.setPort(80);
- fauxmo.enable(true);
- fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
- if(state) {
- servo.write(0);
- }
- else {
- servo.write(70);
- }
- });
- }
- void loop() {
- fauxmo.handle();
- Blynk.run();
- }
- // VIA CHAINE YOUTUBE EMAKERZ, https://www.youtube.com/channel/UCnNRQGz1SSgMGgFZzZRi8PA?view_as=subscriber
Add Comment
Please, Sign In to add comment