Advertisement
Guest User

KOD

a guest
Mar 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include "nRF24L01.h"
  2. #include "RF24.h"
  3. #include <OneWire.h>
  4. #include <DallasTemperature.h>
  5. #include <Servo.h>
  6.  
  7. #define ONE_WIRE_BUS 2
  8.  
  9. OneWire sygnal(ONE_WIRE_BUS);
  10. DallasTemperature sensors(&sygnal);
  11. Servo serwo;
  12.  
  13. float automat = 55; float temperature;
  14.  
  15. RF24 radio(9, 10);
  16. const uint64_t pipe = 0xE8E8F0F0E1LL;
  17. const uint64_t pipe2 = 0xF0F0F0F0AA;
  18.  
  19. void setup() {
  20.  
  21. serwo.attach(7);
  22.  
  23. pinMode(LED_BUILTIN, OUTPUT);
  24. pinMode(8,OUTPUT);
  25. digitalWrite(8,HIGH);
  26.  
  27. sensors.begin();
  28. radio.begin();
  29. radio.openWritingPipe(pipe);
  30. radio.openReadingPipe(1, pipe2);
  31. }
  32.  
  33.  
  34. void loop() {
  35. sensors.requestTemperatures();
  36. temperature = sensors.getTempCByIndex(0);
  37.  
  38. radio.write(&temperature, sizeof(float));
  39.  
  40. radio.startListening();
  41. delay(200);
  42. if (radio.available())
  43. {
  44. radio.read(&automat, sizeof(float));
  45. }
  46. radio.stopListening();
  47.  
  48. if (temperature>automat)
  49. {
  50. digitalWrite(8,HIGH);
  51. }else{
  52. digitalWrite(8,LOW);
  53. }
  54.  
  55. if (temperature<automat+5)
  56. {
  57. serwo.write(180);
  58. }else{
  59. serwo.write(0);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement