Advertisement
Guest User

Untitled

a guest
Dec 24th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #define BLYNK_PRINT Serial
  2. #define CE_PIN 4
  3. #define CSN_PIN 15
  4.  
  5. #include <SPI.h>
  6. #include <nRF24L01.h>
  7. #include <RF24.h>
  8. #include <ESP8266WiFi.h>
  9. #include <BlynkSimpleEsp8266.h>
  10.  
  11. int lampaG = 0;
  12. int pompkiG = 0;
  13. int alarmG = 0;
  14. WidgetLED lampaLED(V5);
  15. WidgetLED pompkiLED(V7);
  16. WidgetLED alarmLED(V9);
  17. BlynkTimer timer;
  18.  
  19. const uint64_t pipe[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
  20. RF24 radio(CE_PIN, CSN_PIN);
  21.  
  22. uint16_t data[6];
  23. uint16_t nowe[6];
  24.  
  25. char auth[] = "xxx";
  26. char ssid[] = "xxx";
  27. char pass[] = "xxx";
  28.  
  29. void setup()
  30. {
  31. Serial.begin(9600);
  32.  
  33. Blynk.begin(auth, ssid, pass);
  34. timer.setInterval(100L, fukcjaFirst);
  35.  
  36.  
  37. radio.begin();
  38. radio.openReadingPipe(1,pipe[0]);
  39. radio.openWritingPipe(pipe[1]);
  40. }
  41.  
  42. BLYNK_WRITE(V6)
  43. {
  44. lampaG = param.asInt();
  45. }
  46.  
  47. BLYNK_WRITE(V8)
  48. {
  49. pompkiG = param.asInt();
  50. }
  51.  
  52. BLYNK_WRITE(V10)
  53. {
  54. alarmG = param.asInt();
  55. }
  56.  
  57. void fukcjaFirst()
  58. {
  59. radio.startListening();
  60. delay(100);
  61. if ( radio.available() )
  62.  
  63. {
  64. radio.read( nowe , sizeof(nowe) );
  65. }
  66.  
  67. if (nowe[0]==1){lampaLED.on();}else{lampaLED.off();}
  68. if (nowe[1]==1){pompkiLED.on();}else{pompkiLED.off();}
  69. if (nowe[2]==1){alarmLED.on();}else{alarmLED.off();}
  70. Blynk.virtualWrite(V3, nowe[3]);
  71. Blynk.virtualWrite(V4, nowe[4]);
  72.  
  73. radio.stopListening();
  74.  
  75. data[0] = lampaG;
  76. data[1] = pompkiG;
  77. data[2] = alarmG;
  78. radio.write( data, sizeof(data) );
  79. }
  80.  
  81. void loop()
  82. {
  83. Blynk.run();
  84. timer.run();
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement