ESP8266 W BLYNK + LED + SLIDER
unknown
c_cpp
8 months ago
1.3 kB
6
Indexable
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6Dg5BN5QY"
#define BLYNK_TEMPLATE_NAME "Tes"
#define BLYNK_AUTH_TOKEN "RwidIib66jvWDhjTnXwi6h-ivNnvN-tz"
#define Led1 D5
#define Led2 D6
#define Led3 D7
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Galaxy S22089D";
char pass[] = "vxfv1284";
bool pinValue1 = LOW;
bool pinValue2 = LOW;
bool pinValue3 = LOW;
int pinValue4;
BlynkTimer timer;
BLYNK_CONNECTED(){
Blynk.syncVirtual(V0);
Blynk.syncVirtual(V1);
Blynk.syncVirtual(V2);
Blynk.syncVirtual(V3);
}
BLYNK_WRITE(V0){
pinValue1 = param.asInt();
}
BLYNK_WRITE(V1){
pinValue2 = param.asInt();
digitalWrite(Led2, pinValue2);
}
BLYNK_WRITE(V2){
pinValue3 = param.asInt();
digitalWrite(Led3, pinValue3);
}
BLYNK_WRITE(V3){
pinValue4 = param.asInt();
int cerah = map(pinValue4, 0, 100, 0 ,255);
if (pinValue1 == HIGH){
analogWrite(Led1, cerah);
} else {
cerah = 0;
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
timer.run();
}Editor is loading...
Leave a Comment