arduino - hc-05 5v - vcc gnd - gnd TX1 - RXD RX0 - TXD arduino - ds1307 5v - 5v gnd - gnd A5 - scl A4 - sda
#include <Wire.h> // i2c #include <iarduino_RTC.h> // rtc ( c, (Timer->firmware_for_timer->iarduino_RTC)) #include <EEPROM.h> // iarduino_RTC time(RTC_DS1307); // int values; // unsigned int to_minutes(unsigned int hours, unsigned int minutes)// { return (60*hours)+minutes; } void setup() { time.begin(); // Serial.begin(9600); // } void loop() { if(Serial.available() > 0) // - { values = Serial.read(); time.settime(0,-1, values); // delay(50); values = Serial.read(); time.settime(0, values); // delay(50); // for (int i = 0 ; i < EEPROM.length() ; i++) { EEPROM.write(i, 0); } ////////////////////////////////// values = Serial.read(); delay(50); // , while (values > 0) // { for(int i = 0; i < 7; ++i) { EEPROM.write(EEPROM.read(EEPROM.length() - 1) * 7 + i, Serial.read()); delay(50); } EEPROM.write(EEPROM.length() - 1, EEPROM.read(EEPROM.length() - 1) + 1); values = Serial.read(); delay(50); } ///////////////////////////////////////// } // for(int i = 0; i < EEPROM.read(EEPROM.length() - 1); ++i) { if(EEPROM.read(i * 7 + 0) == 1) // { bool find = 0; // time.gettime(); if((to_minutes(EEPROM.read(i * 7 + 1), EEPROM.read(i * 7 + 2)) <= to_minutes(time.Hours, time.minutes)) && // (to_minutes(EEPROM.read(i * 7 + 3), EEPROM.read(i * 7 + 4)) > to_minutes(time.Hours, time.minutes))) { pinMode(EEPROM.read(i * 7 + 5), OUTPUT); // digitalWrite(EEPROM.read(i * 7 + 5), EEPROM.read(i * 7 + 6)); // } else // { // for (int j = 0; j < EEPROM.read(EEPROM.length() - 1); ++j) { if(EEPROM.read(i * 7 + 5) == EEPROM.read(j * 7 + 5) && (i != j) && (EEPROM.read(j * 7 + 0) == 1)) { // if((to_minutes(EEPROM.read(j * 7 + 1), EEPROM.read(j * 7 + 2)) <= to_minutes(time.Hours, time.minutes)) && (to_minutes(EEPROM.read(j * 7 + 3), EEPROM.read(j * 7 + 4)) > to_minutes(time.Hours, time.minutes))) // { pinMode(EEPROM.read(i * 7 + 5), OUTPUT); // digitalWrite(EEPROM.read(i * 7 + 5), EEPROM.read(j * 7 + 6)); // find = 1; // } } } if(find == 0) // { pinMode(EEPROM.read(i * 7 + 5), OUTPUT); // digitalWrite(EEPROM.read(i * 7 + 5), !EEPROM.read(i * 7 + 6)); // } } } } }
The application is intuitive and I think there will be no problems with it.But it’s better to understand right away. When you first enter the application, you will need to connect to the bluetooth module, for this, click "synchronize device"
Source: https://habr.com/ru/post/461561/
All Articles