Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- char auth[] = "9cc73cbad1334a7b9a0a78022ff8b4e1";
- char ssid[] = "Hippies-Box";
- char pass[] = "1608195516021964";
- // GPIO12 = D6 = Ansteuerung Relais LOGO Licht Garten
- // GPIO1 = TX = Rückmeldung LOGO Licht Garten
- // GPIO2 = D4 = Ansteuerung Relais LOGO Laterne
- // GPIO3 = RX = Rückmeldung LOGO Laterne
- // GPIO4 = D2 = Ansteuerung Relais LOGO Party
- // GPIO5 = D1 = Rückmeldung LOGO Party
- // GPIO14 = D5 = Ansteuerung Relais 4
- // GPIO13 = D7 = Rückmeldung Relais 4
- const int btnPin1 = 12; // Relais Garten
- const int btnPin2 = 1; // Rückmeldung Garten
- const int btnPin3 = 2; // Relais Laterne
- const int btnPin4 = 3; // Rückmeldung Laterne
- const int btnPin5 = 4; // Relais Party
- const int btnPin6 = 5; // Rückmeldung Party
- const int btnPin7 = 14; // Relais 4
- const int btnPin8 = 13; // Rückmeldung Relais 4
- // V1 = Rückmeldung LOGO Licht Garten
- // V2 = Rückmeldung LOGO Laterne
- // V3 = Rückmeldung LOGO Party
- // V4 = Rückmeldung Relais 4
- WidgetLED led1(V1);
- WidgetLED led2(V2);
- WidgetLED led3(V3);
- WidgetLED led4(V4);
- BlynkTimer timer;
- boolean btnState1 = false;
- void buttonLedWidget1()
- {
- boolean isPressed = (digitalRead(btnPin2) == LOW);
- if (isPressed != btnState1) {
- if (isPressed) {
- led1.on();
- } else {
- led1.off();
- }
- btnState1 = isPressed;
- }
- }
- boolean btnState2 = false;
- void buttonLedWidget2()
- {
- boolean isPressed = (digitalRead(btnPin4) == LOW);
- if (isPressed != btnState2) {
- if (isPressed) {
- led2.on();
- } else {
- led2.off();
- }
- btnState2 = isPressed;
- }
- }
- boolean btnState3 = false;
- void buttonLedWidget3()
- {
- boolean isPressed = (digitalRead(btnPin6) == LOW);
- if (isPressed != btnState3) {
- if (isPressed) {
- led3.on();
- } else {
- led3.off();
- }
- btnState3 = isPressed;
- }
- }
- boolean btnState4 = false;
- void buttonLedWidget4()
- {
- boolean isPressed = (digitalRead(btnPin8) == LOW);
- if (isPressed != btnState4) {
- if (isPressed) {
- led4.on();
- } else {
- led4.off();
- }
- btnState4 = isPressed;
- }
- }
- void setup()
- {
- // Debug console
- Serial.begin(9600);
- Blynk.begin(auth, ssid, pass);
- pinMode(btnPin1, OUTPUT);
- pinMode(btnPin3, OUTPUT);
- pinMode(btnPin5, OUTPUT);
- pinMode(btnPin7, OUTPUT);
- pinMode(btnPin2, INPUT_PULLUP);
- pinMode(btnPin4, INPUT_PULLUP);
- pinMode(btnPin6, INPUT_PULLUP);
- pinMode(btnPin8, INPUT_PULLUP);
- timer.setInterval(1000L, buttonLedWidget1);
- timer.setInterval(1000L, buttonLedWidget2);
- timer.setInterval(1000L, buttonLedWidget3);
- timer.setInterval(1000L, buttonLedWidget4);
- }
- void loop()
- {
- Blynk.run();
- timer.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement