Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "nRF24L01.h"
- #include "RF24.h"
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <Servo.h>
- #define ONE_WIRE_BUS 2
- OneWire sygnal(ONE_WIRE_BUS);
- DallasTemperature sensors(&sygnal);
- Servo serwo;
- float automat = 55; float temperature;
- RF24 radio(9, 10);
- const uint64_t pipe = 0xE8E8F0F0E1LL;
- const uint64_t pipe2 = 0xF0F0F0F0AA;
- void setup() {
- serwo.attach(7);
- pinMode(LED_BUILTIN, OUTPUT);
- pinMode(8,OUTPUT);
- digitalWrite(8,HIGH);
- sensors.begin();
- radio.begin();
- radio.openWritingPipe(pipe);
- radio.openReadingPipe(1, pipe2);
- }
- void loop() {
- sensors.requestTemperatures();
- temperature = sensors.getTempCByIndex(0);
- radio.write(&temperature, sizeof(float));
- radio.startListening();
- delay(200);
- if (radio.available())
- {
- radio.read(&automat, sizeof(float));
- }
- radio.stopListening();
- if (temperature>automat)
- {
- digitalWrite(8,HIGH);
- }else{
- digitalWrite(8,LOW);
- }
- if (temperature<automat+5)
- {
- serwo.write(180);
- }else{
- serwo.write(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement