hello,
a while ago a program was created for ringing bells, which worked well. it happened to me that I lost the data on the disk of the computer on which I had loaded the libraries. I had a copy of the program which I have. I'm having trouble reconnecting to edit the program because I can't find the right libraries. below is the program
report error for lcd library...
hello,
a while ago a program was created for ringing bells, which worked well. it happened to me that I lost the data on the disk of the computer on which I had loaded the libraries. I had a copy of the program which I have. I'm having trouble reconnecting to edit the program because I can't find the right libraries. below is the program
report error for lcd library...
thanks for the help
#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
#define OUR_latitude 46.056946 // Ljubljana
#define OUR_longtitude 14.505752
#define OUR_timezone 120 // localtime with UTC difference in minutes
sunMoon sm;
//definiraj pine
int zvon11 = 4;
int zvon12 = 5;
int zvon21 = 6;
int zvon22 = 7;
int pinButton1 = 8;
int pinButton2 = 9;
int pinButton3 = 10;
/////
byte ura1[8] = {
B00011,
B01110,
B11100,
B11100,
B11100,
B11100,
B01110,
B00011
};
byte customChar1[8] = {
0b00100,
0b01110,
0b11111,
0b00100,
0b00100,
0b00100,
0b00100,
0b00100
};
byte customChar2[8] = {
0b00100,
0b00100,
0b00100,
0b00100,
0b00100,
0b11111,
0b01110,
0b00100
};
byte zvon[8] = {
0b00100,
0b01110,
0b01110,
0b01110,
0b11111,
0b00000,
0b00100,
0b00000
};
void printDate(time_t date)
{
char buff[20];
sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
day(date), month(date), year(date), hour(date), minute(date), second(date));
Serial.print(buff);
}
void Time(time_t date)
{
char buff[20];
sprintf(buff, "%02d:%02d:%02d",
hour(date), minute(date), second(date));
Serial.print(buff);
(buff);
}
//additional function
void printLcdDate(time_t date)
{
char buff[20];
sprintf(buff, "%02d:%02d:%02d",
hour(date), minute(date), second(date));
lcd.print(buff);
}
//additional function
void printLcdDate1(time_t date)
{
char buff[20];
sprintf(buff, "%2d-%02d-%4d",
day(date), month(date), year(date));
lcd.print(buff);
}
void setup()
{
lcd.begin(20, 4);
tmElements_t tm; // specific time
tm.Second = 0;
tm.Minute = 12;
tm.Hour = 12;
tm.Day = 3;
tm.Month = 8;
tm.Year = 2016 - 1970;
time_t s_date = makeTime(tm);
Serial.begin(115200);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
Serial.print("Today is ");
printDate(RTC.get()); Serial.println("");
uint32_t jDay = sm.julianDay(); // Optional call
byte mDay = sm.moonDay();
time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();
Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
Serial.print("Today sunrise and sunset: ");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("\t");
Time(sRise); Serial.print("; ");
Time(sSet); Serial.println("");
lcd.setCursor(10, 0);
printLcdDate1(RTC.get());
lcd.setCursor(2, 2);
printLcdDate(RTC.get());
lcd.setCursor(2, 1);
printLcdDate(sRise);
lcd.setCursor(2, 3);
printLcdDate(sSet);
Serial.print("Specific date was ");
printDate(s_date); Serial.println("");
jDay = sm.julianDay(s_date);
mDay = sm.moonDay(s_date);
sRise = sm.sunRise(s_date);
sSet = sm.sunSet(s_date);
Serial.print("Specific date sunrise and sunset was: ");
Serial.print("Julian day of specific date was "); Serial.println(jDay);
Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("");
//definiraj outpute za relaye
pinMode(zvon11, OUTPUT); // sets the digital pin to output
digitalWrite(zvon11, HIGH); // sets the digital pin LOW
pinMode(zvon12, OUTPUT); // sets the digital pin to output
digitalWrite(zvon12, HIGH); // sets the digital pin LOW
pinMode(zvon21, OUTPUT); // sets the digital pin to output
digitalWrite(zvon21, HIGH); // sets the digital pin LOW
pinMode(zvon22, OUTPUT); // sets the digital pin to output
digitalWrite(zvon22, HIGH); // sets the digital pin LOW
pinMode(pinButton1, INPUT_PULLUP);
pinMode(pinButton2, INPUT_PULLUP);
pinMode(pinButton3, INPUT_PULLUP);
lcd.createChar(1, ura1);
lcd.createChar(2, customChar1);
lcd.createChar(3, customChar2);
lcd.createChar(4, zvon);
/////////////
}
unsigned long prevMillis;
unsigned long TimeInterval = 1000; // milliseconds
void loop()
{
time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();
time_t sunRise(time_t date = 0);
time_t sunSet(time_t date = 0);
time_t timeNow = RTC.get();
printDate(timeNow); Serial.print("\t");
Time(sRise); Serial.print("\t ");
Time(sSet); Serial.println("");
lcd.setCursor(10, 0);
printLcdDate1(timeNow);
lcd.setCursor(2, 2);
printLcdDate(timeNow);
lcd.setCursor(2, 1);
printLcdDate(sRise);
lcd.setCursor(2, 3);
printLcdDate(sSet);
//
lcd.setCursor(13, 1);
lcd.print(" Zvoni:");
lcd.setCursor(13, 2);
lcd.print("07:00");
lcd.setCursor(13, 3);
lcd.print("12:00");
lcd.setCursor(0, 0);
lcd.print("Danes je:");
lcd.setCursor(0, 2);
lcd.write(byte(1));
lcd.setCursor(0, 1);
lcd.write((byte)2);
lcd.setCursor(0, 3);
lcd.write((byte)3);
lcd.setCursor(11, 3);
lcd.write((byte)4);
lcd.setCursor(19, 2);
lcd.write((byte)4);
lcd.setCursor(19, 3);
lcd.write((byte)4);
if(millis()-prevMillis > TimeInterval)
{
prevMillis=millis();
}
// Jutranje zvonenje---- 7.00------1 zvon- veliki
if (hour(timeNow) == 7 && minute(timeNow) == 0 && second(timeNow) == 0)
{
Ring_1_Bells();
}
// Opopdan zvonenje----- 12.00-----1 zvon- veliki
if (hour(timeNow) == 12 && minute(timeNow) == 0 && second(timeNow) == 0)
{
Ring_1_Bells();
//RingSunsetBells();
}
// ZveÄŤerno zvonenje (sunset)------2 zvonova
if (sSet == timeNow)
{
RingSunsetBells();
}
//////////////////////////////////////////////////////////RoÄŤni vklopi////////////////////////////////
// Gumb jutranje
int stateButton1 = digitalRead(pinButton1);
if(stateButton1 == LOW)
{
Ring_1_Bells();
}
// Gumb veÄŤerno
int stateButton2 = digitalRead(pinButton2);
if(stateButton2 == LOW)
{
RingSunsetBells();
}
// Gumb smrt
int stateButton3 = digitalRead(pinButton3);
if(stateButton3 == LOW)
{
smrt();
}
}
//////////jutranje ----- opoldne///////////////////////////////////////////////zvon 1------> dvostransko zvonenje
void Ring_1_Bells()
{
for (int lp = 0; lp < 70; lp++)
{
digitalWrite(zvon11, LOW);
delay(475);
digitalWrite(zvon11, HIGH);
delay(145);
digitalWrite(zvon12, LOW);
delay(470);
digitalWrite(zvon12, HIGH);
delay(150);
}
}
////////////ZveÄŤerno/////////////////////////////////////////zvon 1 in 2
/////////////////////////////////prvi cikelj-----> enostransko zvonenje
void RingSunsetBells()
{
for (int lp = 0; lp < 40; lp++)
{
digitalWrite(zvon11, LOW);
delay(0);
digitalWrite(zvon11, HIGH);
delay(630);
digitalWrite(zvon12, LOW);
delay(450);
digitalWrite(zvon12, HIGH);
delay(180);
}
delay(2000);
////////////////////////////////drugi cikelj----> enostransko zvonenje
for (int lp = 0; lp < 40; lp++)
{
digitalWrite(zvon21, LOW);
delay(0);
digitalWrite(zvon21, HIGH);
delay(575);
digitalWrite(zvon22, LOW);
delay(430);
digitalWrite(zvon22, HIGH);
delay(145);
}
delay(2000);
//////////////////////////////tretji cikelj------> dvostransko zvonenje
for (int lp = 0; lp < 40; lp++)
{
digitalWrite(zvon11, LOW);
delay(475);
digitalWrite(zvon11, HIGH);
delay(145);
digitalWrite(zvon12, LOW);
delay(470);
digitalWrite(zvon12, HIGH);
delay(150);
}
}
//////////smrt//////////////////// zvonenje za smrt----> dvostransko
void smrt()
{
for (int lp = 0; lp < 35; lp++)
{
digitalWrite(zvon21, LOW);
delay(160);
digitalWrite(zvon21, HIGH);
delay(400);
digitalWrite(zvon22, LOW);
delay(300);
digitalWrite(zvon22, HIGH);
delay(260);
}
}