Skip to content

Instantly share code, notes, and snippets.

@sobstel
Last active July 11, 2023 15:28
Show Gist options
  • Save sobstel/195b48cde1ece9f88f5f1480b9b1e51d to your computer and use it in GitHub Desktop.
Save sobstel/195b48cde1ece9f88f5f1480b9b1e51d to your computer and use it in GitHub Desktop.
CODE_delorean_clock_V4_SUMMER.ino [UPDATED]
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
#include "RTClib.h"
// Sortie horloge Rouge
const byte PIN_CLK_Red = A0; // define CLK pin
// Sortie horloge Verte
const byte PIN_CLK_Green = A1; // define CLK pin
// Sortie horloge Orange
const byte PIN_CLK_Orange = A2; // define CLK pin
//RED Displays
const byte PIN_DIO_R1 = 3;
SevenSegmentExtended red1(PIN_CLK_Red, PIN_DIO_R1);
const byte PIN_DIO_R2 = 4;
SevenSegmentTM1637 red2(PIN_CLK_Red, PIN_DIO_R2);
const byte PIN_DIO_R3 = 5;
SevenSegmentExtended red3(PIN_CLK_Red, PIN_DIO_R3);
//GREEN Displays
const byte PIN_DIO_G1 = 6;
SevenSegmentExtended green1(PIN_CLK_Green, PIN_DIO_G1);
const byte PIN_DIO_G2 = 7;
SevenSegmentTM1637 green2(PIN_CLK_Green, PIN_DIO_G2);
const byte PIN_DIO_G3 = 8;
SevenSegmentExtended green3(PIN_CLK_Green, PIN_DIO_G3);
int greenAM = 12;
int greenPM = 13;
// ORANGE Displays
const byte PIN_DIO_O1 = 9; // define DIO pin (any digital pin)
SevenSegmentExtended orange1(PIN_CLK_Orange, PIN_DIO_O1); // SegmentExtended pour utiliser la methode "PrintTime"
const byte PIN_DIO_O2 = 10;
SevenSegmentTM1637 orange2(PIN_CLK_Orange, PIN_DIO_O2); //SegmentTM1637 pour utiliser la methode "print" permet d'enlever les ":" entre les chiffres
const byte PIN_DIO_O3 = 11;
SevenSegmentExtended orange3(PIN_CLK_Orange, PIN_DIO_O3);
bool parse=false;
bool config=false;
int Hour=0;
RTC_DS3231 rtc;
int orange_backlight = 30;
int green_backlight = 50;
int red_backlight = 10;
void setup() {
pinMode(PIN_CLK_Red, OUTPUT);
pinMode(PIN_CLK_Green, OUTPUT);
pinMode(PIN_CLK_Orange, OUTPUT);
pinMode(PIN_DIO_O1, OUTPUT);
pinMode(PIN_DIO_O2, OUTPUT);
pinMode(PIN_DIO_O3, OUTPUT);
pinMode(PIN_DIO_G1, OUTPUT);
pinMode(PIN_DIO_G2, OUTPUT);
pinMode(PIN_DIO_G3, OUTPUT);
pinMode(PIN_DIO_R1, OUTPUT);
pinMode(PIN_DIO_R2, OUTPUT);
pinMode(PIN_DIO_R3, OUTPUT);
pinMode(greenPM, OUTPUT);
pinMode(greenAM, OUTPUT);
Serial.begin(9600); // initializes the Serial connection @ 9600 baud
orange1.begin(); // initializes the display
orange2.begin();
orange3.begin();
green1.begin();
green2.begin();
green3.begin();
red1.begin();
red2.begin();
red3.begin();
orange1.setBacklight(orange_backlight);
orange2.setBacklight(orange_backlight);
orange3.setBacklight(orange_backlight);
green1.setBacklight(green_backlight);
green2.setBacklight(green_backlight);
green3.setBacklight(green_backlight);
red1.setBacklight(red_backlight);
red2.setBacklight(red_backlight);
red3.setBacklight(red_backlight);
#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif
Serial.begin(9600);
// delay(3000); // wait for console opening
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
//Red displays - Destination TIME
red1.print("0629");
red2.print(1986);
red3.printTime(12, 00, false);
// Orange Displays - Last time departed
orange1.print("1218");
orange2.print(2022);
orange3.printTime(16, 00, false);
}
void loop() {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
////Lighting AM/PM
//Hour=now.hour(); // Heure d'été
Hour=now.hour()-1; // Heure d'hiver
if(Hour>=12){
digitalWrite(greenAM,1);
digitalWrite(greenPM,0);
}else if(Hour==11){
digitalWrite(greenAM,0);
digitalWrite(greenPM,1);
}else if(Hour==-1){
Hour=23;
digitalWrite(greenAM,0);
digitalWrite(greenPM,1);
}
else{
digitalWrite(greenAM,1);
digitalWrite(greenPM,0);
}
//Green Displays - Present TIME
String month = String(now.month());
if(now.month()<10) month = "0"+month;
String day = String(now.day());
if(now.day()<10) day = "0"+day;
green1.print(month + day);
green2.print(now.year());
green3.printTime(Hour, now.minute(), true);
if (now.minute()==0 && now.second()==0) green3.blink();
delay(1000);
}
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
#include "RTClib.h"
// Sortie horloge Rouge
const byte PIN_CLK_Red = A0; // define CLK pin
// Sortie horloge Verte
const byte PIN_CLK_Green = A1; // define CLK pin
// Sortie horloge Orange
const byte PIN_CLK_Orange = A2; // define CLK pin
//RED Displays
const byte PIN_DIO_R1 = 3;
SevenSegmentExtended red1(PIN_CLK_Red, PIN_DIO_R1);
const byte PIN_DIO_R2 = 4;
SevenSegmentTM1637 red2(PIN_CLK_Red, PIN_DIO_R2);
const byte PIN_DIO_R3 = 5;
SevenSegmentExtended red3(PIN_CLK_Red, PIN_DIO_R3);
//GREEN Displays
const byte PIN_DIO_G1 = 6;
SevenSegmentExtended green1(PIN_CLK_Green, PIN_DIO_G1);
const byte PIN_DIO_G2 = 7;
SevenSegmentTM1637 green2(PIN_CLK_Green, PIN_DIO_G2);
const byte PIN_DIO_G3 = 8;
SevenSegmentExtended green3(PIN_CLK_Green, PIN_DIO_G3);
int greenAM = 12;
int greenPM = 13;
// ORANGE Displays
const byte PIN_DIO_O1 = 9; // define DIO pin (any digital pin)
SevenSegmentExtended orange1(PIN_CLK_Orange, PIN_DIO_O1); // SegmentExtended pour utiliser la methode "PrintTime"
const byte PIN_DIO_O2 = 10;
SevenSegmentTM1637 orange2(PIN_CLK_Orange, PIN_DIO_O2); //SegmentTM1637 pour utiliser la methode "print" permet d'enlever les ":" entre les chiffres
const byte PIN_DIO_O3 = 11;
SevenSegmentExtended orange3(PIN_CLK_Orange, PIN_DIO_O3);
bool parse=false;
bool config=false;
int Hour=0;
RTC_DS3231 rtc;
int orange_backlight = 30;
int green_backlight = 50;
int red_backlight = 10;
void setup() {
pinMode(PIN_CLK_Red, OUTPUT);
pinMode(PIN_CLK_Green, OUTPUT);
pinMode(PIN_CLK_Orange, OUTPUT);
pinMode(PIN_DIO_O1, OUTPUT);
pinMode(PIN_DIO_O2, OUTPUT);
pinMode(PIN_DIO_O3, OUTPUT);
pinMode(PIN_DIO_G1, OUTPUT);
pinMode(PIN_DIO_G2, OUTPUT);
pinMode(PIN_DIO_G3, OUTPUT);
pinMode(PIN_DIO_R1, OUTPUT);
pinMode(PIN_DIO_R2, OUTPUT);
pinMode(PIN_DIO_R3, OUTPUT);
pinMode(greenPM, OUTPUT);
pinMode(greenAM, OUTPUT);
Serial.begin(9600); // initializes the Serial connection @ 9600 baud
orange1.begin(); // initializes the display
orange2.begin();
orange3.begin();
green1.begin();
green2.begin();
green3.begin();
red1.begin();
red2.begin();
red3.begin();
orange1.setBacklight(orange_backlight);
orange2.setBacklight(orange_backlight);
orange3.setBacklight(orange_backlight);
green1.setBacklight(green_backlight);
green2.setBacklight(green_backlight);
green3.setBacklight(green_backlight);
red1.setBacklight(red_backlight);
red2.setBacklight(red_backlight);
red3.setBacklight(red_backlight);
#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif
Serial.begin(9600);
// delay(3000); // wait for console opening
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(2018, 6, 20, 17, 10, 30));
}
//Red displays - Destination TIME
red1.print("0629");
red2.print(1986);
red3.printTime(12, 00, false);
// Orange Displays - Last time departed
orange1.print("1218");
orange2.print(2022);
orange3.printTime(16, 00, false);
}
void loop() {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
////Lighting AM/PM
//Hour=now.hour(); // Heure d'été
Hour=now.hour(); // Heure d'hiver
if(Hour>=12){
digitalWrite(greenAM,1);
digitalWrite(greenPM,0);
}else if(Hour==11){
digitalWrite(greenAM,0);
digitalWrite(greenPM,1);
}else if(Hour==-1){
Hour=23;
digitalWrite(greenAM,0);
digitalWrite(greenPM,1);
}
else{
digitalWrite(greenAM,1);
digitalWrite(greenPM,0);
}
//Green Displays - Present TIME
String month = String(now.month());
if(now.month()<10) month = "0"+month;
String day = String(now.day());
if(now.day()<10) day = "0"+day;
green1.print(month + day);
green2.print(now.year());
green3.printTime(Hour, now.minute(), true);
if (now.minute()==0 && now.second()==0) green3.blink();
delay(1000);
}
@sobstel
Copy link
Author

sobstel commented Nov 5, 2021

07437F67-B7BC-4048-9E2F-E70105D17C07_1_105_c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment