Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial
- #define CE_PIN 4
- #define CSN_PIN 15
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- int lampaG = 0;
- int pompkiG = 0;
- int alarmG = 0;
- WidgetLED lampaLED(V5);
- WidgetLED pompkiLED(V7);
- WidgetLED alarmLED(V9);
- BlynkTimer timer;
- const uint64_t pipe[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
- RF24 radio(CE_PIN, CSN_PIN);
- uint16_t data[6];
- uint16_t nowe[6];
- char auth[] = "xxx";
- char ssid[] = "xxx";
- char pass[] = "xxx";
- void setup()
- {
- Serial.begin(9600);
- Blynk.begin(auth, ssid, pass);
- timer.setInterval(100L, fukcjaFirst);
- radio.begin();
- radio.openReadingPipe(1,pipe[0]);
- radio.openWritingPipe(pipe[1]);
- }
- BLYNK_WRITE(V6)
- {
- lampaG = param.asInt();
- }
- BLYNK_WRITE(V8)
- {
- pompkiG = param.asInt();
- }
- BLYNK_WRITE(V10)
- {
- alarmG = param.asInt();
- }
- void fukcjaFirst()
- {
- radio.startListening();
- delay(100);
- if ( radio.available() )
- {
- radio.read( nowe , sizeof(nowe) );
- }
- if (nowe[0]==1){lampaLED.on();}else{lampaLED.off();}
- if (nowe[1]==1){pompkiLED.on();}else{pompkiLED.off();}
- if (nowe[2]==1){alarmLED.on();}else{alarmLED.off();}
- Blynk.virtualWrite(V3, nowe[3]);
- Blynk.virtualWrite(V4, nowe[4]);
- radio.stopListening();
- data[0] = lampaG;
- data[1] = pompkiG;
- data[2] = alarmG;
- radio.write( data, sizeof(data) );
- }
- void loop()
- {
- Blynk.run();
- timer.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement