big seven segment clock

Another arduino based colorful clock and thermometer using rainbow changing colors or whatever static color you like

This was , for some unknown reason, one of the most stubborn projects i’ve ever made..

At the beginning i wanted to use a number of white leds to light up the segments but a number of stupid mistakes i`ve made in the design process , problems with the damn pc , external projects that had to be done and other shitty mishaps (life happened) it took me almost a year of dickin around with this thing

The initial plan was to light up the white leds using a combination of uln2008 and pnp transistors. Because the leds were supposed to use 12v i realized that my high side switching was insufficient and could potentially fry the arduino. So updates were made to avoid this

The result was a hot mess of wires on the board resulting to , yet again , another failure… I was fed up , i said to my self “you know what?fuck this shit!” .I’ve ditched the whole board and the white leds and decided to use a ws2815b led strip i had laying around for another project .

The whole display uses just 28 leds in a row for the numbers and 2 leds for the dots and the can run directly from the arduino`s 5v rail. I used 2 different data channels seperate for the numbers and the dots.A new board was made , everything was much cleaner and simpler now and an additional board for the buttons was made. Luckily the leds could be powered by the arduino but it was nessesary to send power to more points of the leds because of the extremely small wires i used

Unfortunately i dont have any pictures from the back of the display since i got in a building frenzy since i was tired of all this bullshit and wanted to finish ASAP

The initial 3d model for the clock can be found here
https://www.thingiverse.com/thing:3062461
so most of the work was done already and i`ve scaled the parts to 70% and printed it with using as little infill as i could (somethin like 5%). Also i had to design different back covers and cover for the boards. (more links about those will be posted soon)

There are 4 buttons on the clock. Set hour , Set minutes, and setting up and down. Pressing set hour and up/down , sets hours up or down ,
Pressing set mins and up/down..yeap.. you guesed it..

Now if you press set Hour and set Min changes the color mode. By default there`s this rainbow effect , but pressing those to sets you to a stationary color setting. Using the up/down buttons lets you select the color. Again pressing set hour and set min changes the mode back to rainbow effect

Heres a short demostration video

 

So heres the code

#include 
#include 

#define NUM_LEDS 28
#define DATA_PIN 3
#define DOTS_PIN 4
#define SET_BT_MIN 5
#define SET_BT_HOUR 6
#define UP_BT 9
#define DOWN_BT 8

CRGB leds[NUM_LEDS];
CRGB dots[2];
DS3231  rtc(SDA, SCL);
Time  t;//global time

#define OFF CRGB::Black
#define BRIGHTNESS  255

int time_duration = 10;//poso xrono 8a deixnei thn wra prin allaksei o8onh
int temp_duration = 2;//poso xrono 8ermokrasia
int ct = 0;
int displayState = 1;//1:deixnei wra , 2:deixnei 8ermokrasia
int dotState = 0;
int disp=1;
int n = 0;

int testsled = 0;
int theme = 0;
uint8_t gHue = 0;
uint8_t newHue = 0;
int color[] = {0, 255, 0};
//-------> direction ----> of pixels
int pinMatrix[12][7] = {
  {1, 1, 1, 1, 1, 1, 0},//0
  {0, 0, 0, 0, 1, 1, 0},//1
  {1, 0, 1, 1, 0, 1, 1},//2
  {1, 0, 0, 1, 1, 1, 1},//3
  {0, 1, 0, 0, 1, 1, 1},//4
  {1, 1, 0, 1, 1, 0, 1},//5
  {1, 1, 1, 1, 1, 0, 1},//6
  {1, 0, 0, 0, 1, 1, 0},//7
  {1, 1, 1, 1, 1, 1, 1},//8
  {1, 1, 0, 1, 1, 1, 1},//9
  {1, 1, 0, 0, 0, 1, 1},//va8moi[10] (kyklaki)
  {1, 1, 1, 1, 0, 0, 0}//kelsiou[11]
};

int colorMatrix[28];//edw 8a einai ta xrwmata gia to ka8e led

void setup() {
    rtc.begin();
    pinMode(LED_BUILTIN, OUTPUT);
    pinMode(SET_BT_MIN, INPUT);
    pinMode(SET_BT_HOUR, INPUT);
    pinMode(UP_BT, INPUT);
    pinMode(DOWN_BT, INPUT);
   	delay(2000);//gia na parei mpros
    FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
    FastLED.addLeds<NEOPIXEL, DOTS_PIN>(dots, 2);
    FastLED.setBrightness(  BRIGHTNESS );
 
    rainbowColors();//ka8orizoume to arxiko xrwma
}

void rainbowColors(){
  for(int c = 0;c<NUM_LEDS;c++){
    colorMatrix[c] = gHue;
    gHue += 3 ;//gia tyxaia xrwmata
  }
}

void showNumber(int num , int dsp){
  int startPx = 0;
  int endPx = 0;
  int c = 0;

  //epilogh display se led range
  if(dsp == 1) {
    startPx = 21;
    endPx = 27;
  }
  if(dsp == 2){
    startPx = 14;
    endPx = 20;
  }
  if(dsp == 3){
    startPx = 7;
    endPx = 13;
  }
  if(dsp == 4){
    startPx = 0;
    endPx = 6;
  }

  //epilogh pattern sta analoga led
  for(int n=startPx; n<=endPx; n++){
    int sh = pinMatrix[num][c];
    if(sh == 1) {
      leds[n] = CHSV( colorMatrix[n], 255, 255);
    } else leds[n] = OFF;
    c++;
  }
  FastLED.show();
}

void colorTheme(){
  if(theme == 0){//rainbow effect
    EVERY_N_MILLISECONDS( 20 ) { //afto yparxei sto fast led mono
      for(int c = 0;c<NUM_LEDS;c++){
        colorMatrix[c] = colorMatrix[c]+1;
      }
    }
  }
  if(theme == 1){
    for(int c = 0;c<NUM_LEDS;c++){
      colorMatrix[c] = newHue;
    }
  }
}

void showStuff(){
  int temp = round(rtc.getTemp());
  int set1 = digitalRead(SET_BT_MIN);
  int set2 = digitalRead(SET_BT_HOUR);

  if(displayState == 1 || set1 == HIGH || set2 == HIGH){//deikse wra
    if(dotState == 1){
      dots[1] = CHSV( colorMatrix[13], 255, 255);
      dots[0] = CHSV( colorMatrix[14], 255, 255);
    } else {
      dots[1] = OFF;
      dots[0] = OFF;
    }
    
    int minu = t.min;
    int hor = t.hour;
    
    int8_t Digit0 = minu %10 ;
    int8_t Digit1 = (minu % 100) / 10 ;
    int8_t Digit2 = hor % 10 ;
    int8_t Digit3 = (hor % 100) / 10 ;

    showNumber(Digit0 , 4);
    showNumber(Digit1 , 3);
    showNumber(Digit2 , 2);
    showNumber(Digit3 , 1);

  } else if(displayState == 2){//deikse 8ermokrasia

    dots[1] = OFF;
    dots[0] = OFF;
    
    int8_t Digit0 = temp %10 ;
    int8_t Digit1 = (temp % 100) / 10 ;

    showNumber(11 , 4);//kelsiou
    showNumber(10 , 3);//va8moi
    showNumber(Digit0 , 2);//monades
    showNumber(Digit1 , 1);//dekades
    
  }
   //enallagh o8onhs time temp
   EVERY_N_SECONDS(1){//de mas noiazei to apolyto timing
    if(dotState == 0) dotState = 1;
    else dotState = 0;

    if(displayState == 1) {
      if(ct == time_duration){
        displayState = 2;
        ct = 0;
      }
    } else {
      if(ct==temp_duration){
        displayState = 1;
        ct = 0;
      }
    }
    ct++; 
  }
}

void readButtons(){
  int setBt_min_read = digitalRead(SET_BT_MIN);
  int setBt_hour_read = digitalRead(SET_BT_HOUR);
  int upBt_read = digitalRead(UP_BT);
  int downBt_read = digitalRead(DOWN_BT);

  if(upBt_read == HIGH){
    if(setBt_min_read == HIGH){
        displayState = 1;
        int new_min = t.min+1;
        rtc.setTime(t.hour, new_min, 0);
        delay(200);
    } else if(setBt_hour_read == HIGH){
        displayState = 1;
        int new_hour = t.hour+1;
        rtc.setTime(new_hour, t.min, 0);
        delay(200);
    } else {
      if(newHue == 255) newHue = 0;
      else newHue += 10;
      delay(200);
    }
  }

  if(downBt_read == HIGH){
    if(setBt_min_read == HIGH){
        displayState = 1;
        int new_min = t.min-1;
        rtc.setTime(t.hour, new_min, 0);
        delay(200);
    } else if(setBt_hour_read == HIGH){
        displayState = 1;
        int new_hour = t.hour-1;
        rtc.setTime(new_hour, t.min, 0);
        delay(200);
    } else {
      if(newHue == 0) newHue = 255;
      else newHue -= 10;
      delay(200);
    }
  }

  if(setBt_min_read == HIGH && setBt_hour_read == HIGH){
    if(theme == 1){
      rainbowColors();
      theme = 0;
    }
    else theme++;
    delay(200);
  }
}

void loop() {
  t = rtc.getTime();//global
  showStuff();
  readButtons();
  colorTheme();
}

more information will be added soon