Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- #include "dallas.h"
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <Timers.h> // my favorite timer
- Timers <2> akcja; //
- char auth[] = "f845be3b89e74d28b164bd8a9c1d38ba"; //konto na local server konto blynk.pl@gmail.com
- char ssid[] = "xxxxxxxxxx";
- char pass[] = "yyyyyyyyyyyyyy";
- #define led_blue 14
- #define led_bialy 12
- #define klaw1 4
- #define klaw2 5
- #define BLYNK_GREEN "#23C48E"
- #define BLYNK_BLUE "#04C0F8"
- #define BLYNK_YELLOW "#ED9D00"
- #define BLYNK_RED "#D3435C"
- #define BLYNK_DARK_BLUE "#5F7CD8"
- #define _RED "#FF0000"
- #define _GREEN "#00FF00"
- int button1=0;
- void testklaw();
- void setup()
- {
- pinMode(led_blue, OUTPUT); //LED niebieski
- pinMode(led_bialy, OUTPUT); //LED bialy
- pinMode(klaw1, INPUT);
- pinMode(klaw2, INPUT);
- Serial.begin(115200);
- delay(100);
- Serial.println();
- Serial.println();
- Serial.println(F(__FILE__)); //BLYNK .4.8 Arduino IDE.cc 1.8.3
- akcja.attach(0, 1000, timer1sek); // 1 sek
- setdallas(); //setup for ds18b20
- Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 2, 19));
- }
- void loop()
- {
- akcja.process(); // timer
- Blynk.run();
- }
- void timer1sek() { //różne rzeczy wykonywane cyklicznie
- sensorT(); //dallas
- testklaw();
- }
- void testklaw()
- {
- int k1 = digitalRead(klaw1);
- if (k1 == 1) {
- } else {
- Blynk.virtualWrite(V1, HIGH);
- Blynk.setProperty(V1, "onLabel", "press klaw1");
- }
- int k2 = digitalRead(klaw2);
- if (k2 == 1) {
- Blynk.setProperty(V1, "color", BLYNK_GREEN);
- } else {
- Blynk.virtualWrite(V1, HIGH);
- Blynk.setProperty(V1, "onLabel", "press klaw2");
- Blynk.setProperty(V1, "color", _RED);
- }
- if(button1 == 4){
- Blynk.setProperty(V1, "onLabel", tempstr);
- }
- }
- // Blynk.setProperty(V0, "color", gaugeColor); onLabel
- BLYNK_WRITE(V1)
- {
- button1 = param.asInt(); // assigning incoming value from pin V1 to a variable
- // You can also use: String i = param.asStr(); double d = param.asDouble();
- if (button1 == 0) {
- digitalWrite(led_blue, HIGH);
- digitalWrite(led_bialy, HIGH);
- Blynk.setProperty(V1, "onLabel", "on");
- };
- if (button1 == 1) {
- digitalWrite(led_blue, LOW);
- };
- if (button1 == 2) {
- digitalWrite(led_bialy, LOW);
- };
- if (button1 == 3) {
- digitalWrite(led_blue, LOW);
- digitalWrite(led_bialy, LOW);
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement