Hello Sterretje
I've got a LCD like this :
http://www.ebay.fr/itm/1284-1602-16x2-HD44780-Character-LCD-Display-Module-yellow-Blacklight-arduino-/292036692546?var=&hash=item43febe4a42:m:mHNzFiDuKczbMBLpyUH4Qqg
(but before having it, I had freeze also)
a RTC1307 like this :
http://www.ebay.fr/itm/Module-tiny-RTC-DS1307-I2C-horloge-Real-Time-Clock-avec-pile-Arduino-DIY-/322072366318?hash=item4afd024cee:g:5DoAAOSwu-BWOjR~
(but before having it, I had freeze also)
a relay with optocoupler like this :
http://www.ebay.fr/itm/5V-1-Channel-Relay-Shield-Module-With-Optocoupler-For-PIC-AVR-DSP-ARM-Arduino-/263057485728?hash=item3d3f72afa0:g:z8QAAOSwLsBZUMze
Have a led to send a signal that tell some loop is still running (although the LCD send the seconds too)
the power supply 9v like the one I posted on my former post.
with decoupler devices.
I'll make the drawing schematic tomorrow.
This is a device to power a bell, a kind of chime, 4 times a day. 2 calls "make food" and 2 calls "come to have lunch/dinner"
Code is still a little dirty...
This code is currently running on 2 Unos. One on a Chinese Uno is working perfectly for ... 1 day and a half on the real bell, and another is genuine Uno working on a buzzer at the output (no relay).
This second one had a bug today, it starts ringing almost continuously, it was because the "test" pin8 was configured input but was not connected to anything, even without a wire plugged into the arduino connector, but it was sensing some electricity from the air and detecting. Now directly plugged into grnd, no problem anymore.
but as you can notice, I try everything, including the watchdog (not in use now ) but the watchdog did not stop the uno from freezing.
I also made a code for making my gate automatic (not descripted here) same problem. Was working properly, but after a certain time, will freeze.
Comments are in French, I hope it's not a problem ?
Now I send the code :
#include <Adafruit_SleepyDog.h>
#include <LiquidCrystal.h>
#include <RTClib.h>
#include <Wire.h>
RTC_DS1307 RTC; //Classe RTC_DS1307
//declaration du format heure
int temps ;
//nommer la variable de sonnerie
const int ring = 10 ;
//choix des heures de sonneries en heures pleines, en fixe (constantes) hfairemidi veut dire heure de faire midi
const int hfairemidi = 11;
const int hmidi =12;
const int hfairediner = 17;
const int hdiner = 18;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // a l'origine 5, 4, 3, 2);
void setup () {
Serial.begin(9600); //Démarrage de la communication
Wire.begin(); //Démarrage de la librairie wire.h
RTC.begin(); //Démarrage de la librairie RTClib.h
lcd.begin(16, 2); //démarrage du LCD
//Si RTC ne fonctionne pas
if (! RTC.isrunning()) {
Serial.println("RTC ne fonctionne pas !");
}
// RTC.adjust(DateTime("Sept 3 2017","06:50:00")); //ligne a reactiver a la bonne date pour faire une mise a l'heure
// initialize the digital pin as an output.
pinMode(ring, OUTPUT);
pinMode(9, OUTPUT); //pin pour verification du processus
}
void attends(){
for(int I =1 ; I<60 ; I++)
{
lcd.setCursor(0, 0); lcd.print(" ");
lcd.setCursor(0, 1); lcd.print(" ");
lcd.setCursor(0, 0); lcd.print(" attente apres ");
lcd.setCursor(0, 2); lcd.print(" tintement");
digitalWrite(9,HIGH);delay(50);digitalWrite(9,LOW); //diode temoin de passage dans la boucle
//Watchdog.enable(4000);
if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
Serial.print("touche test on"); delay (30);
}
delay(900);
}}
//sonnerie à la volée
void volee()
{
lcd.setCursor(0, 0); lcd.print(" ");
lcd.setCursor(0, 1); lcd.print("son de volee ");
//debut avec une double
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);
//Watchdog.reset();
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(2000);
//Watchdog.reset();
//isolée
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();
delay(1600);
//Watchdog.reset();
//tintements à 1 seconde
for(int B =1 ; B<=3 ; B++)
{
//isolée
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();
delay(900);
}
//Watchdog.reset();
// double
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(2000);
//Watchdog.reset();
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(3000);
//Watchdog.reset();
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);
//Watchdog.reset();
attends(); //attente une minute afin de ne pas refaire la sonnerie tout de suite
}
void loop() {
if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
Serial.print("touche test on");
}
if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
volee();
}
//Watchdog.reset();
// digitalWrite(11,LOW); //extinction diode check de marche de cette boucle
//Affichage de l'heure
DateTime now = RTC.now();
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
lcd.setCursor(0, 0); lcd.print(" ");
lcd.setCursor(0, 1); lcd.print(" ");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); lcd.print(now.hour());
lcd.setCursor(3, 0); lcd.print("H");
lcd.setCursor(5, 0);lcd.print(now.minute());
lcd.setCursor(9, 0); lcd.print("min");
lcd.setCursor(14, 0); lcd.print(now.second());
temps = now.hour();
delay(150);
//lcd.noDisplay();//éteint le lcd pour effacer l'écran
delay(150);
//lcd.display();//rallume le lcd
digitalWrite(9,HIGH);delay(50);digitalWrite(9,LOW); //diode temoin de passage dans la boucle
//Watchdog.disable();
//sonneries :
if(hfairemidi==now.hour() && now.minute() == 0)
{son2coups();
}
if(hmidi==now.hour() && now.minute() == 0)
{volee();
}
if(hfairediner==now.hour() && now.minute() == 30)
{son2coups();
}
if(hdiner==now.hour() && now.minute() == 30)
{volee();
}
}
//sonnerie à deux fois deux coups
void son2coups(){
lcd.setCursor(0, 0); lcd.print(" ");
lcd.setCursor(0, 1); lcd.print("son deux coups ");
for(int B =1 ; B<=3 ; B++)
//premiers deux coups
{
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(900);
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();
//attente intermediaire
delay(3000);
//Watchdog.reset();
}
//derniers deux coups
//digitalWrite(ring, HIGH);
//delay(100);
//digitalWrite(ring, LOW);
//delay(900);
//digitalWrite(ring, HIGH);
//delay(100);
//digitalWrite(ring, LOW);
//Watchdog.reset();
attends(); //attente une minute afin de ne pas refaire la sonnerie tout de suite
}