// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud // See the Device Info tab, or Template settings //------------------------------------------------------------------------------------------------------------------------- #define BLYNK_TEMPLATE_ID "TMPL3i79777P3" #define BLYNK_TEMPLATE_NAME "Interface trial" #define BLYNK_AUTH_TOKEN "TB5Pv8f1Ee2tTP7Iw_q3yPuPg6O2Tqgb" //-------------------------------------------------------------------------------------------------------------------------- // Comment this out to disable prints and save space #define BLYNK_PRINT Serial //-------------------------------------------------------------------------------------------------------------------------- // Initialize required libraries #include #include //-------------------------------------------------------------------------------------------------------------------------- char auth[] = BLYNK_AUTH_TOKEN; char ssid[] = "Sothpot"; // Wifi name. Case, space sensitive char pass[] = "qwerty135"; // Wifi passowrd. Case, space sensitive. Set password to "" for open networks. //-------------------------------------------------------------------------------------------------------------------------- int potValue = A0; // Assign pin A0 to read potentiometer value //-------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------- void setup() { pinMode(potValue, INPUT); // Define pin A0 as input. (Potentiometer) pinMode(02, OUTPUT); // Define pin D4 as output. (LED) pinMode(04, OUTPUT); // Define pin D2 as output. (LED) // Debug console Serial.begin(115200); Blynk.begin(auth, ssid, pass, "blynk.cloud", 80); // Initialize Blynk parameters } //-------------------------------------------------------------------------------------------------------------------------- // Virtual Pin V1. This function takes value from pin V0 from Blynk and updates it on ESP board. BLYNK_WRITE(V1) { int pinValue = param.asInt(); // Assigning incoming value from pin V1 to a variable if (pinValue == 1) { digitalWrite(02, HIGH); } else { digitalWrite(02, LOW); } } //-------------------------------------------------------------------------------------------------------------------------- // Virtual Pin V2. This function takes value from pin V2 from Blynk and updates it on ESP board. BLYNK_WRITE(V2) { int PWMValue = param.asInt(); // Assigning incoming value from pin V2 to a variable analogWrite (04,PWMValue); } //-------------------------------------------------------------------------------------------------------------------------- void loop() { Blynk.run(); int potValue = analogRead(A0); Blynk.virtualWrite(V0, potValue); // Sends Analog value to Blynk. Assign V1 to gauge }