Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_GFX.h>
- #include <MCUFRIEND_kbv.h>
- MCUFRIEND_kbv tft;
- #include "RTClib.h"
- RTC_PCF8523 rtc;
- #define BLACK 0x0000 // Variables contenant la valeur sur 16 bits des couleurs
- #define WHITE 0xFFFF
- uint16_t g_identifier; // Identifiant de l'écran TFT
- uint8_t OrientationTFT = 1;
- const int Broche_Relais1 = 37; //neons UVB
- const int Broche_Relais2 = 35; //lampe chauffante
- int Hrs = 0;
- int LastHrs = 0;
- void setup(){
- pinMode(Broche_Relais1, OUTPUT);
- pinMode(Broche_Relais2, OUTPUT);
- digitalWrite(Broche_Relais1, HIGH);
- digitalWrite(Broche_Relais2, HIGH);
- tft.begin(9600); // Démarre la communication avec l'écran TFT
- tft.reset(); // Initialise l'écran TFT
- g_identifier = tft.readID(); // Lecture de l'identifiant de l'écran TFT
- tft.begin(g_identifier); // Démarre la librairie de l'écran TFT
- tft.fillScreen(BLACK); // Initialise la couleur du fond d'écran
- tft.setRotation(OrientationTFT);
- if (! rtc.begin()) {
- }
- if (! rtc.initialized()) {
- }
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- void loop(){
- gestionHorloge();
- }
- void gestionHorloge(){ //partie horloge
- DateTime now = rtc.now();
- tft.setTextColor(WHITE,BLACK);
- tft.setCursor(100, 5);
- tft.setTextSize(3);
- if (now.hour() < 10) {tft.print('0');}
- tft.print(now.hour(), DEC);
- tft.print(':');
- if (now.minute() < 10) {tft.print('0');}
- tft.print(now.minute(), DEC);
- tft.print(':');
- if (now.second() < 10) {tft.print('0');}
- tft.print(now.second(), DEC);
- if(now.hour()==8&&now.minute()==00&&now.second()<=1){ //programmation eclairages
- digitalWrite(Broche_Relais1, HIGH);
- digitalWrite(Broche_Relais2, HIGH);
- }
- else if(now.hour()==22&&now.minute()==00&&now.second()<=1){
- digitalWrite(Broche_Relais1, LOW);
- digitalWrite(Broche_Relais2, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement