#include <LiquidCrystal.h>
#include <Wire.h>
#include <DS3231.h>
#include "pitches.h"
DS3231 clock;
RTCDateTime dt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte cloche[8] = {0b00100, 0b01110, 0b01110, 0b01110, 0b01110, 0b11111, 0b00000, 0b00100};
int HAlarm = 07;
int melody[] = {
NOTE_C5, NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6
};
int duration = 500;
void setup()
{
clock.setDateTime(2014, 4, 13, 19, 21, 00);
clock.begin();
lcd.begin(16, 2);
lcd.createChar(0, cloche);
clock.setDateTime(2017, 5, 23, 6, 2, 58);
}
void loop()
//clock.dateFormat("d m y H i s", dt);
{
dt = clock.getDateTime();
lcd.setCursor(0, 0);
lcd.print(clock.dateFormat("H:i:s", dt));
lcd.setCursor(0, 1);
lcd.print(clock.dateFormat("D d/m/y", dt));
lcd.setCursor(13, 0);
lcd.write(byte(0));
lcd.print(HAlarm);
lcd.print("H");
TestAlarm();
}
void TestAlarm()
{
if (clock.dateFormat("H", dt) == 6)
{
if (clock.dateFormat("i", dt) > 2)
{
if (clock.dateFormat("i", dt) < 5)
{
if (clock.dateFormat("N", dt) < "6")
{
Alarm();
}
}
}
}
}
void Alarm()
{
for (int thisNote = 0; thisNote < 8; thisNote++)
{
tone(7, melody[thisNote], duration);
delay(1000 / 8);
}
}
J'ai fait des test et les if du void TestAlarm() ne fonctionne pas.
Je ne trouve pas de solution ...