Date

Fermé
chamessmaa Messages postés 1 Date d'inscription mardi 9 juin 2015 Statut Membre Dernière intervention 9 juin 2015 - 9 juin 2015 à 18:05
slt , j'ai réalisé une application mais j'ai un petit problème, mon application et de faire un affichage pour la date et l'heure a partir d'un ds1307 et , faire l'affichage de l'humidité et la température a partir d'un DHT11 l'affichage ce fait sure un écran LCD , aussi une carte arduino qui ce fonctionne tout ca , et j'ai des événement qui son affiche au cours de l'année a partir du date comme hiver (du décembre -------> février) mais le problème , lorsque je fait une modification du mois et jour a partir du bouton pour voir les affichage saisonnière elle ne mémorise pas cette modification
aidez moi svp
#include <LiquidCrystal.h>
#include <Time.h>
#include <Wire.h> //* communication série serial print
#include <DS1307RTC.h>
#include <dht.h>
dht DHT; //*
#define DHT11_PIN A0
LiquidCrystal lcd(8, 9, 7, 6, 5, 4);
const int b1 = 13;
const int b2 = 12;
const int b3 = 11;
const int b4 = 10;
tmElements_t tm; //* pointeur fih tm.minute tm.hou....
void setup() {
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
pinMode(b4, INPUT);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" BIEN VENUE ");
lcd.setCursor(0, 1);
lcd.print(" ISET JENDOUBA ");
delay(5000);
lcd.clear();
}
void loop() {
lcd.clear();
tmElements_t tm; //*
if (RTC.read(tm)) { //* bech ya9ra pointeur mel rtc

lcd.setCursor(0, 0);
lcd.print("Temp: ");
print2digits(tm.Hour);
lcd.print(":");
print2digits(tm.Minute);
lcd.print(":");
print2digits(tm.Second);
lcd.setCursor(0, 1);
lcd.print("Date: ");
print2digits(tm.Day);
lcd.print("/");

print2digits(tm.Month); //*

lcd.print("/");
print2digits(tmYearToCalendar(tm.Year-30)); //* bech ya9ra el 3am mel calendrier


if ((tm.Month == 1) && (tm.Day > 13))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" Les nuits noires ");
}
if ((tm.Month == 2) && (tm.Day < 3))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" Les nuits noires ");
}
if ((tm.Month == 2) && (tm.Day > 2))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" Loures de froid ");
}
if ((tm.Month == 2) && (tm.Day < 14))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" Loures de froid ");
}
if ((tm.Month == 2) && (tm.Day > 13))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" le grand froid ");
}
if ((tm.Month == 2) && (tm.Day < 19))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print(" Loures de froid ");
}
if ((tm.Month == 2) && (tm.Day > 21))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("rechauffement de l'air ");
}
if ((tm.Month == 2) && (tm.Day < 28))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("rechauffement de l'air ");
}
if ((tm.Month == 2) && (tm.Day > 27))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Debut de primptemps ");
}
if ((tm.Month == 3) && (tm.Day < 6))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Debut fr primptemps");
}
if ((tm.Month == 3) && (tm.Day > 5))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("rechauffement de la terre");
}
if ((tm.Month == 3) && (tm.Day < 10))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("rechauffement de la terre");
}
if ((tm.Month == 3) && (tm.Day > 9))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Jours intercalaires ");
}
if ((tm.Month == 3) && (tm.Day < 18))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Jours intercalaires");
}
if ((tm.Month == 3) && (tm.Day > 17))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Printemps");
}
if ((tm.Month == 3) && (tm.Day < 21))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Printemps ");
}
if ((tm.Month == 3) && (tm.Day == 21))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Equinoxe");
}
if ((tm.Month == 3) && (tm.Day > 21))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Printemps ");
}
if ((tm.Month == 3) && (tm.Day < 29))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Printemps");
}
if ((tm.Month == 4) && (tm.Day > 28))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Debut ETE");
}
if ((tm.Month == 4) && (tm.Day < 19))
{
lcd.clear();
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Debut l'été");
}
if ((tm.Month == 6) && (tm.Day == 9)&& (tm.Second==30))
{
lcd.clear();
lcd.setCursor(2, 0);
// print the number of seconds since reset:
lcd.print("Debut ETE");
lcd.setCursor(4, 1);
// print the number of seconds since reset:
lcd.print("Debut ETE");
delay(15000);
}

if (tm.Second==1){
lcd.clear();

int chk = DHT.read11(DHT11_PIN); //*


// Envio a LCD
lcd.setCursor(0, 0);
lcd.print("Temp.: ");
lcd.print(DHT.temperature);
lcd.print((char)223); //*
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humed: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(15000);

}
if (digitalRead(b4) == 1) {


lcd.setCursor(6, 0);
lcd.noCursor(); //*

lcd.cursor(); //*

if (digitalRead(b3) == 1) {

tm.Hour = tm.Hour +1;
delay(500);

lcd.print(tm.Hour);
}
if (digitalRead(b2) == 1) {
tm.Hour = tm.Hour - 1;
delay(500);
lcd.print(tm.Hour);
}

if (digitalRead(b1) == 1) {

lcd.setCursor(9, 0);
lcd.noCursor();

lcd.cursor();

if (digitalRead(b3) == 1) {
tm.Minute = tm.Minute + 1;
delay(500);
lcd.print(tm.Minute);
}
if (digitalRead(b2) == 1) {
tm.Minute = tm.Minute - 1;
delay(500);

lcd.print(tm.Minute);
}
}

if (digitalRead(b1) == 1) {
delay(500);
lcd.setCursor(12, 0);
lcd.noCursor();

lcd.cursor();


if (digitalRead(b3) == 1) {
tm.Second = tm.Second + 1;
delay(500);

lcd.print(tm.Second);
}
if (digitalRead(b2) == 1) {
tm.Second = tm.Second - 1;
delay(500);

lcd.print(tm.Second);
}
}

if (digitalRead(b1) == 1) {
delay(500);
lcd.setCursor(6, 1);
lcd.noCursor();

lcd.cursor();

if (digitalRead(b3) == 1) {
tm.Day = tm.Day + 1;
delay(500);

lcd.print(tm.Day);
}
if (digitalRead(b2) == 1) {
tm.Day = tm.Day - 1;
delay(500);

lcd.print(tm.Day);
}
}

if (digitalRead(b1) == 1) {
delay(500);
lcd.setCursor(9, 1);
lcd.noCursor();

lcd.cursor();

if (digitalRead(b3) == 1) {
tm.Month = tm.Month + 1;
delay(500);

lcd.print(tm.Month);
}
if (digitalRead(b2) == 1) {
tm.Month = tm.Month - 1;
delay(500);

lcd.print(tm.Month);
}
}

if (digitalRead(b1) == 1) {
delay(500);
lcd.setCursor(12, 1);
lcd.noCursor();

lcd.cursor();


if (digitalRead(b3) == 1) {
tm.Year = tm.Year + 1;
delay(500);

lcd.print(tm.Year);
}
if (digitalRead(b2) == 1) {
tm.Year = tm.Year - 1;
delay(500);

lcd.print(tm.Year);
}
}
}


} else {
if (RTC.chipPresent()) { //* enregistre wa9et hors connexion
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
delay(9000);
}
delay(1000);
}
void print2digits(int number) { //*

if (number >= 0 && number < 10) { //*

lcd.print('0');
}
lcd.print(number);
}