Se afișează postările cu eticheta 7 segmente. Afișați toate postările
Se afișează postările cu eticheta 7 segmente. Afișați toate postările

miercuri, 26 decembrie 2018

Ceas reglabil animat cu termometru şi higrometru pe afisaj multiplexat cu 4 cifre led

 
    Am adăugat ceasului cu prezentare informaţii animate şi reglaj al ceasului şi datei, pentru a putea avea un ceas independent. Am păstrat si reglajul intensităţii (automat sau manual) cum e prezentat în articolul precedent.
sau 

    Am adăugat doar 2 butoane fără reţinere (pushbutoane) la pinii A1, respectiv A2:
   Schema de bază rămânând aceeaşi
    Apăsând butonul MENU/MENIU se intră în modul de reglaj, întâi al orelor care clipesc repede şi creşte valoare la fiecare apăsare a butonului +, dar dacă se ajunge la 23 şi s eappară o să avem ora 00.
   Dacă se apasă iar butonul MENIU se intră în meniul de reglare al minutelor, care clipesc mai repede, iar valoarea lor creşte prin apăsarea butonului + (sau menţinerea apăsată pentru creştere mai rapidă) până la 59, după care trece la 00.
   La următoarea apăsare a butonului MENIU apare anul, care poate fi schimba doar de la 2018 la 2049
urmează schimbarea lunilor de la 1 la 12
apoi prin apăsarea butonului MENIU se intră la reglarea zilelor, care depind de luna şi an (pentru februarie), în acest mod zilele clipesc rapid pentru a şti ce se modifică
  Acest mod de reglaj l-am găsit la Andy pe blog in articolul Arduino Astronomical Clock (or Arduino Pond Pump Controller!)  şi mi-a plăcut modul de implementare, aşa că l-am tot folosit de-a lungul timpului.
   Sketch-ul folosit este multiplexed_scroll_clock3.ino şi în filmuleţele următoare se vede foarte bine modul de funcţionare şi cum se face reglajul

vineri, 7 noiembrie 2014

Modul de afisare cu 8 cifre LED din 7 segmente fiecare controlate de MAX7219

   Am achizitionat de pe Banggood.com un modul de afisare cu 8 cifre LED din 7 segmente fiecare, care sunt comandate de integratul MAX7219.
   MAX7219 poate controla 64 de LED-uri, cum e cazul acestor 8 cifre din 7 segmente + punctul zecimal la fiecare sau o matrice de 8x8 LED-uri.
   In acel articol sunt prezentate niste scurte exemple, in care se utilizeaza libraria LedControl.h si din comenzile de acolo am facut schema:
   Am incercat si eu sketch-urile din articol si din exemplu, modificand unul pentru a afisa cum vreau sa afisez pentru o viitoare statie meteo cu ceas:
si un anume text:
 
   Sketch-ul folosit de mine este:
// adapted sketch by niq_ro from http://www.tehnic.go.ro
// http://nicuflorica.blogspot.ro/
// http://arduinotehniq.blogspot.com/

// orginal sketch from http://embedded-lab.com/blog/?p=6862
#include "LedControl.h" 
/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

void setup()
{
// Initialize MAX7219 device
lc.shutdown(0,false); // Enable display 
lc.setIntensity(0,15); // Set brightness level (0 is min, 15 is max) 
lc.clearDisplay(0); // Clear display register 
//} 
}

void loop()
{

// test afisare un anumit text
lc.clearDisplay(0); // Clear display register 
lc.setDigit(0,7,2, false); // afisez un 2 pe prima coloana din stanga (coloane 7)
lc.setDigit(0,6,5, true); // afisez un 5 pe coloana 6 si un punct zecimal
lc.setDigit(0,5,4, false); // afisez un 4 pe coloana 5
lc.setRow(0,4,B1001110);
lc.setDigit(0,2,3, false); // afisez un 5 pe coloana 2
lc.setDigit(0,1,7, false); // afisez un 0 pe coloana 1
lc.setRow(0,0,B0110111);

delay(3000);

// fac alt text
lc.clearDisplay(0); // Clear display register 
lc.setDigit(0,7,1, false); // afisez un 1 pe prima coloana din stanga (coloane 7)
lc.setDigit(0,6,2, false); // afisez un 2 pe coloana 6 si un punct zecimal
lc.setRow(0,5,B00000001);
lc.setDigit(0,4,4, false); // afisez un "4" pe coloana 4
lc.setDigit(0,3,2, false); // afisez un "2" pe coloana 3
lc.setRow(0,2,B00000001);
lc.setDigit(0,1,3, false); // afisez un 3 pe coloana 1
lc.setDigit(0,0,6, false); // afisez un 6 pe prima coloana din dreapta, pe coloana 0

delay(3000);

// fac inca un text
lc.clearDisplay(0); // Clear display register 
lc.setRow(0,6,B01100010); // "n" sus 
lc.setRow(0,5,B00100000); // "i" sus 
lc.setRow(0,4,B01110011); // "q" sus 
lc.setRow(0,3,B00000001); // bara la mijloc 
lc.setRow(0,2,B01000010); // "r" sus 
lc.setRow(0,1,B01100011); // "o" sus

delay(3000);
}
   Am facut un film cu testele, numit
test afisaj 8 cifre LED cu 7 segmente fiecare si Arduino, cu un scketch putin modificat:
   Am conectat un senzor DHT11:
   Initial, am lasat sa masoare la 10 secunde:
dar apar variatii bruste de temperaturi: 24, 25 sau 260C, care ma deranjeaza.
    Sketch-ul scris de mine, din combinarea altora, care folosesc librariile LedControl.h si DHT.h este:
// adapted sketch by niq_ro from http://arduinotehniq.blogspot.com
// and http://nicuflorica.blogspot.ro
// version 1.0 in 6.11.2014, Craiova - Romanaia

// source for LEDControl: http://embedded-lab.com/blog/?p=6862
#include "LedControl.h" 
/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN 7     // what pin we're connected to D7
// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// if is just sensor:
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

// decralaration for type of value
int t, h;

void setup()
{
// Initialize MAX7219 device
lc.shutdown(0,false); // Enable display 
lc.setIntensity(0,11); // Set brightness level (0 is min, 15 is max) 
lc.clearDisplay(0); // Clear display register 
 
// Initialize HTD sensor
dht.begin();
}

void loop()
{
 // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
h = dht.readHumidity();
t = dht.readTemperature();
  
/* test part  
// test humidity value
h = 37;
// test temperature value
t = 19;
*/

// 
temperatura (t);
umiditate (h);
delay(10000);
}


void umiditate (int umidit)
{
int zu = int(umidit/10); // determin cifra zecilor
int uu = umidit - 10*zu; // determin cifra unitatilor
  
lc.setDigit(0,2,zu, false); // afisez un 5 pe coloana 2
lc.setDigit(0,1,uu, false); // afisez un 0 pe coloana 1
lc.setRow(0,0,B0110111);  // afisez litera "H"
}


void temperatura (int temper)
{
int zt = int(temper/10); // determin cifra zecilor
int ut = temper - 10*zt; // determin cifra unitatilor
  
lc.setDigit(0,7,zt, false); // afisez un 5 pe coloana 7
lc.setDigit(0,6,ut, false); // afisez un 0 pe coloana 1
lc.setRow(0,5,B1100011); // afisez un semn de grad pe coloana 5
lc.setRow(0,4,B1001110); // afisez un C pe coloana 4
}
   Apoi am facut o medie de 9 masuratori si a ultimei temperaturi afisate, fiecare masuratoare fiind la 2 secunde, obtinand ceva mai aproape de adevar:

   Sketch-ul adaptat si scris de mine este:
// adapted sketch by niq_ro from http://arduinotehniq.blogspot.com
// and http://nicuflorica.blogspot.ro
// version 1.2 in 6.11.2014, Craiova - Romania

// source for LEDControl: http://embedded-lab.com/blog/?p=6862
#include "LedControl.h" 
/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN 7     // what pin we're connected to D7
// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// if is just sensor:
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

// decralaration for type of value
int t, h; 
float tmed;
int tmed1; 

void setup()
{
// Initialize MAX7219 device
lc.shutdown(0,false); // Enable display 
lc.setIntensity(0,11); // Set brightness level (0 is min, 15 is max) 
lc.clearDisplay(0); // Clear display register 
 
// Initialize HTD sensor
dht.begin();

// inital value for tmperature
tmed = 200;
}

void loop()
{
 // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
h = dht.readHumidity();

tmed = tmed/10;
for(int i = 9 ; i >0  ; i--) {
t = dht.readTemperature();
tmed = tmed + t;
delay(2000);
}
tmed1 = tmed;  // valoarea de inmultita cu zere pentru usurinta afisarii

/* test part  
// test humidity value
h = 37;
// test temperature value
t = 19;
*/

// 
temperatura (tmed1);
umiditate (h);
delay(1000);
}


void umiditate (int umidit)
{
int zu = int(umidit/10); // determin cifra zecilor
int uu = umidit - 10*zu; // determin cifra unitatilor
 
lc.setDigit(0,2,zu, false); // afisez un 5 pe coloana 2
lc.setDigit(0,1,uu, false); // afisez un 0 pe coloana 1
lc.setRow(0,0,B0110111);  // afisez litera "H"
}


void temperatura (int temper)
{
int st = int(temper/100); // determin cifra sutelor
temper = temper - 100*st; // restul numarului de la zeci si unitati 
int zt = int(temper/10); // determin cifra zecilor
int ut = temper - 10*zt; // determin cifra unitatilor
  
lc.setDigit(0,7,st, false); // afisez un 5 pe coloana 7
lc.setDigit(0,6,zt, true); // afisez un 0 pe coloana 1 si virgula
lc.setDigit(0,5,ut, false); // afisez un 5 pe coloana 7
//lc.setRow(0,5,B1100011); // afisez un semn de grad pe coloana 5
lc.setRow(0,4,B1001110); // afisez un C pe coloana 4
}
   Am facut si un filmulet cu cele 2 variante de prezentare, numit temperatura si umiditate de la un DHT11 pe afisaj cu 8 cifre din 7 segmente LED:
   Am in plan si alte experimente, cu conectarea unui modul RTC (ceas de timp real), cu senzorul de umiditate si temperatura DHT22, etc...

vineri, 10 ianuarie 2014

Afisaj LCD16x2 cu caractere mari fata de un afisaj LED cu 4 cifre din 7 segmente

    Din dorinta de a putea vedea temperaturile de la distanta cat mai mare pe un afisaj alfanumeric cu 16 coloane si 2 randuri, LCD16x2 sau 1602, am folosit caractere mari (util 3 coloane + un spatiu, pe ambele randuri), dupa cum am prezentat in articolul anterior, Caractere mari pe afisaj de 2 randuri si 16 coloane si... Arduino (2):
   Mi-am amintit ca am folosit si afisaj LED cu 4 cifre din 7 segmente fiecare, iar articolul se numeste Afisaje LED cu 7 segmente si.. Arduino (II):
  Pentru a le compara usor, am pus cele 2 afisaje unul langa altul:
  Am facut si 2 filmulete:
 
   Dupa acesta comparatie, pot spune ca e mai avantajos din punct de vedere economic sa folosim un afisaj LED, cat si al consumului, deoarece comanda la cel LED e multiplexata, deci se aprinde pe rand doar o cifra/simbol, iar la cel LCD e LED-ul de fundal plus consum afisaj.. dar partea importanta e aceea de vizibilitate, care este tot in favoarea afisajului clasic, tip LED.

marți, 5 noiembrie 2013

Refolosirea unui afisaj de ceas "caramida din lemn" (II)

   In articolul precedent am folosit pentru partea ceas propriu-zis (ore si minute) informatiile oferite de un ceas de timp real cu DS1307, acum o sa folosesc libraria Time.h care se bazeaza pe functia millis(), care numara milisecundele de la alimentarea placii Arduino.
   Intr-un articol numit 12.4Using Arduino as a Clock sunt date si exemple de programele (sketch-uri) inclusiv un exemplu de crestere, respectiv scadere a minutelor, dar eu l-am adaptat sa modific orele si minutele, in sens crescator.
   Un ceas, care foloseste ceasul intern al lui Arduino si senzorul DHT11 pentru temperatura si umiditate, se comporta similar cu cel prezentat in articolul anterior, vedeti filmuletul humidity and temperature with DHT11 using 7-segment LED from a broken wood brick clock (IX)
iar varianta cu posibilitate de reglaj, are filmuletul numit humidity and temperature with DHT11 using 7-segment LED from a broken wood brick clock (X)
   Pentru prima varianta, schema este cea folosita si anterior:
Sketch-ul:
/*
 6-13-2011
 Spark Fun Electronics 2011
 Nathan Seidle

 This code is public domain but you buy me a beer if you use this and we meet 
 someday (Beerware license).

 4 digit 7 segment display:
 http://www.sparkfun.com/products/9483
 Datasheet: 
 http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf

 This is an example of how to drive a 7 segment LED display from an ATmega
 without the use of current limiting resistors. This technique is very common 
 but requires some knowledge of electronics - you do run the risk of dumping 
 too much current through the segments and burning out parts of the display. 
 If you use the stock code you should be ok, but be careful editing the 
 brightness values.

 This code should work with all colors (red, blue, yellow, green) but the 
 brightness will vary from one color to the next because the forward voltage 
 drop of each color is different. This code was written and calibrated for the 
 red color.

 This code will work with most Arduinos but you may want to re-route some of 
 the pins.

 7 segments
 4 digits
 1 colon
 =
 12 pins required for full control 

 */
// modified connexion by niq_ro from http://nicuflorica.blogspot.com
// for my Luckylight KW4-563ASA
// dataseet: http://www.tme.eu/ro/Document/dfc2efde2e22005fd28615e298ea2655/KW4-563XSA.pdf

int digit1 = 11; //PWM Display pin 12 (digit1 is common anonds A1 from right side)
int digit2 = 10; //PWM Display pin 9 (digit2 is  common A2)
int digit3 = 9; //PWM Display pin 8 (digit3 is common anods A3)
int digit4 = 6; //PWM Display pin 6 (digit4 is common anods, from left side)

//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = 2; //Display pin 11
int segB = 3; //Display pin 7
int segC = 4; //Display pin 4
int segD = 5; //Display pin 2
int segE = 12; //Display pin 1
int segF = 7; //Display pin 10
int segG = 8; //Display pin 5
int segDP = 13; // Display pin 3

#include "DHT.h"
#define DHTPIN A2     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11 
DHT dht(DHTPIN, DHTTYPE);

#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
// original sketck from http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/
// add part with SQW=1Hz from http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/


void setup() {

  Wire.begin();
  RTC.begin();
 RTC.adjust(DateTime(__DATE__, __TIME__));
// if you need set clock... just remove // from line above this

// part code for flashing LED
Wire.beginTransmission(0x68);
Wire.write(0x07); // move pointer to SQW address
// Wire.write(0x00); // turns the SQW pin off
 Wire.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave at 1Hz
// Wire.write(0x13); // sends 0x13 (hex) 00010011 (binary) 32kHz

Wire.endTransmission();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  
  
 dht.begin();

  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(segDP, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  
//  pinMode(13, OUTPUT);

 Serial.begin(9600);
 Serial.println("test for niq_ro");
}


// here begin the main program
void loop() 
{

int h = dht.readHumidity();
int t = dht.readTemperature();

// display the temperatura
if (t < 10) // if temperature is < 10 degree
{
 for(int i = 1000 ; i >0  ; i--) {
     temperatura2(t); // this is number to diplay
   }
}
else  // if temperature is > 10 degree
 {for(int i = 1000 ; i >0  ; i--) {
     temperatura1(t); // this is number to diplay
   }
 } 

// display the humidity
   for(int i = 1000 ; i >0  ; i--) {
     umidit(h); // this is number to diplay
   }


digitalWrite(segDP, HIGH);
  DateTime now = RTC.now();
  int tp = now.hour()*100 + now.minute();
  int minutzi = now.minute()/10;
//   int timp = (now.minute(), DEC);
//   displayNumber(12); // this is number to diplay
//   int timp = 1234;
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(" -> ");
  Serial.print(tp);
  Serial.println(" !");
  Serial.print(minutzi);
  Serial.print("=");
 

// here begin part with clock display
if (tp > 999)
{
  switch (minutzi) {
  case 3: 
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora12(tp); 
     for(int i = 250 ; i >0  ; i--) ora32(tp); 
     for(int i = 250 ; i >0  ; i--) ora12(tp); 
     for(int i = 250 ; i >0  ; i--) ora32(tp); 
     for(int i = 250 ; i >0  ; i--) ora12(tp); 
     break;
   
   case 1: 
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora11(tp); 
     for(int i = 250 ; i >0  ; i--) ora31(tp); 
     for(int i = 250 ; i >0  ; i--) ora11(tp); 
     for(int i = 250 ; i >0  ; i--) ora31(tp); 
     for(int i = 250 ; i >0  ; i--) ora11(tp); 
     break;
     
   case 4:
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora13(tp); 
     for(int i = 250 ; i >0  ; i--) ora33(tp); 
     for(int i = 250 ; i >0  ; i--) ora13(tp); 
     for(int i = 250 ; i >0  ; i--) ora33(tp); 
     for(int i = 250 ; i >0  ; i--) ora13(tp); 
     break;
   
   default:  
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora10(tp); 
     for(int i = 250 ; i >0  ; i--) ora30(tp); 
     for(int i = 250 ; i >0  ; i--) ora10(tp); 
     for(int i = 250 ; i >0  ; i--) ora30(tp); 
     for(int i = 250 ; i >0  ; i--) ora10(tp);
    } 
}
else
  {
  switch (minutzi) {
  case 3:
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora22(tp); 
     for(int i = 250 ; i >0  ; i--) ora42(tp); 
     for(int i = 250 ; i >0  ; i--) ora22(tp); 
     for(int i = 250 ; i >0  ; i--) ora42(tp); 
     for(int i = 250 ; i >0  ; i--) ora22(tp); 
     break;
   
  case 1:
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora21(tp);  
     for(int i = 250 ; i >0  ; i--) ora41(tp); 
     for(int i = 250 ; i >0  ; i--) ora21(tp); 
     for(int i = 250 ; i >0  ; i--) ora41(tp); 
     for(int i = 250 ; i >0  ; i--) ora21(tp);
     break;
   
   case 4:
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora23(tp); 
     for(int i = 250 ; i >0  ; i--) ora43(tp); 
     for(int i = 250 ; i >0  ; i--) ora23(tp); 
     for(int i = 250 ; i >0  ; i--) ora43(tp); 
     for(int i = 250 ; i >0  ; i--) ora23(tp);
     break;
     
   default:
     Serial.print(minutzi);
     for(int i = 250 ; i >0  ; i--) ora20(tp); 
     for(int i = 250 ; i >0  ; i--) ora40(tp); 
     for(int i = 250 ; i >0  ; i--) ora20(tp); 
     for(int i = 250 ; i >0  ; i--) ora40(tp); 
     for(int i = 250 ; i >0  ; i--) ora20(tp);
}
 }
 
  Serial.println("? good");
}

/*
//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off

//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//Each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)
*/


// if temperature is >= 10 degree Celsius
void temperatura1(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(12); // display C letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 

// if temperature is < 10 degree Celsius
void temperatura2(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_OFF);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(12); // display C letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// for humidity
void umidit(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
 for(int digit = 4 ; digit > 0 ; digit--) {
   //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(13); // display "o" letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10
void ora10(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      digitalWrite(segDP, LOW);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora11(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora12(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora13(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 



// clock for hour <10
void ora20(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
    digitalWrite(digit1, DIGIT_OFF);
     lightNumber(10); // off first value
     digitalWrite(segDP, HIGH);
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora21(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour <10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora22(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora23(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10
void ora30(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora31(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora32(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP, HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora33(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 



// clock for hour <10
void ora40(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
    digitalWrite(digit1, DIGIT_OFF);
     lightNumber(10); // off first value
     digitalWrite(segDP, HIGH);
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora41(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour <10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora42(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP,HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora43(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, HIGH);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 




//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  // all segment are ON
  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  
  // degree symbol made by niq_ro
  case 11:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  // C letter made by niq_ro
  case 12:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  
 // "o mic" letter made by niq_ro
  case 13:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;
    
 // "rotated 3" made by niq_ro
  case 33:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;
 
 // "rotated 1" made by niq_ro
  case 31:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;
    
  // "rotated 4" made by niq_ro
  case 34:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break; 
  }
}
   Pentru reglaj al orelor si minutelor se completeaza schema cu 2 taste (butoane fara retinere):
iar un sketch, care functioneaza este:
// niq_ro's sketch made ​​from a combination of several programs from web
// see also http://www.nicuflorica.blogspot.com
int digit1 = 11; 
int digit2 = 10; 
int digit3 = 9; 
int digit4 = 6; 

int segA = 2; 
int segB = 3; 
int segC = 4; 
int segD = 5; 
int segE = 12;
int segF = 7; 
int segG = 8; 
int segDP = 13; 

#include "DHT.h"
#define DHTPIN A2     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11 
DHT dht(DHTPIN, DHTTYPE);

#include <Time.h>
// see https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-12/recipe-12-4

//const int  btnhour = 14;   // button to move hour up 
//const int  btnminute = 15; // button to move minute up
//int minut = 0;
//int ora = 0;


void setup() {

 dht.begin();

  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(segDP, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  
//  pinMode(13, OUTPUT);

 Serial.begin(9600);
 Serial.println("test for niq_ro");
 
 setTime(20,55,0,2,11,13); // set time at 20:55 in 02.nov.2013
 Serial.println("20:55 - 02.11.2013");
 
 
 // digitalWrite(btnhour, HIGH);   // enable internal pull-up resistors
 // digitalWrite(btnminute, HIGH); // enable internal pull-up resistors
  digitalWrite(A0, HIGH);   // enable internal pull-up resistors
  digitalWrite(A1, HIGH); // enable internal pull-up resistors
 
 
}


// here begin the main program
void loop() 
{

  digitalClockDisplay();
//  delay(1000);
  
//   while(digitalRead(btnminute)== LOW)
   while(digitalRead(A1)== LOW)
  {
     int m= minute()+1;
     setTime(hour(),m,0,2,11,13);
     digitalClockDisplay(); // update clock   
     delay(500); 
  }
  
   while(digitalRead(A0)== LOW)
  {
     int has= hour()+1;
     setTime(has,minute(),0,2,11,13);
     digitalClockDisplay(); // update clock   
     delay(500); 
  }
  
  
  
  
int h = dht.readHumidity();
int t = dht.readTemperature();

// display the temperatura
if (t < 10) // if temperature is < 10 degree
{
 for(int i = 1000 ; i >0  ; i--) {
     temperatura2(t); // this is number to diplay
   }
}
else  // if temperature is > 10 degree
 {for(int i = 1000 ; i >0  ; i--) {
     temperatura1(t); // this is number to diplay
   }
 } 

// display the humidity
   for(int i = 1000 ; i >0  ; i--) {
     umidit(h); // this is number to diplay
   }


digitalWrite(segDP, HIGH);
//  DateTime now = RTC.now();
//  int tp = now.hour()*100 + now.minute();
//  int minutzi = now.minute()/10;

int tp = hour()*100 + minute();
int minutzi = minute()/10;


  Serial.print(hour(), DEC);
  
  Serial.print(":");
 // Serial.print(now.minute(), DEC);
  Serial.print(minute(), DEC);
  Serial.print(" -> ");
  Serial.print(tp);
  Serial.println(" !");
  Serial.print(minutzi);
  Serial.print("=");
 

// here begin part with clock display
if (tp > 999)
{
  switch (minutzi) {
  case 3: 
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora12(tp); 
     break;
   
   case 1: 
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora11(tp); 
     break;
     
   case 4:
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora13(tp); 
     break;
   
   default:  
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora10(tp); 
    } 
}
else
  {
  switch (minutzi) {
  case 3:
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora22(tp); 
     break;
   
  case 1:
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora21(tp);  
     break;
   
   case 4:
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora23(tp); 
     break;
     
   default:
     Serial.print(minutzi);
     for(int i = 1000 ; i >0  ; i--) ora20(tp); 
  }
 }
 
  Serial.println("? good");
}


// if temperature is >= 10 degree Celsius
void temperatura1(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(12); // display C letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 

// if temperature is < 10 degree Celsius
void temperatura2(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_OFF);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(12); // display C letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// for humidity
void umidit(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
 for(int digit = 4 ; digit > 0 ; digit--) {
   //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      lightNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      lightNumber(11); // display degree symbol
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      lightNumber(13); // display "o" letter
      delayMicroseconds(DISPLAY_BRIGHTNESS); 
      break;
    }
     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10
void ora10(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      digitalWrite(segDP, LOW);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora11(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour >=10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora12(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour >=10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora13(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 



// clock for hour <10
void ora20(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
    digitalWrite(digit1, DIGIT_OFF);
     lightNumber(10); // off first value
     digitalWrite(segDP, HIGH);
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      digitalWrite(segDP, LOW);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 1x
// ora e din 2 cifre si minutele incep cu cifra 1...
void ora21(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(31); // display rotated 1 number
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 

// clock for hour <10 and minutes is 3x
// ora e din 2 cifre si minutele incep cu cifra 3...
void ora22(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(33); // display rotated 3
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 


// clock for hour <10 and minutes is 4x
// ora e din 2 cifre si minutele incep cu cifra 4...
void ora23(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
  for(int digit = 4 ; digit > 0 ; digit--) {
    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
     lightNumber(toDisplay % 10);
       toDisplay /= 10;
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      digitalWrite(segDP, LOW);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
       break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      lightNumber(34); // display rotated 4
      digitalWrite(segDP, LOW);
    //   lightNumber(toDisplay % 10);
        toDisplay /= 10;
    
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      digitalWrite(segDP, HIGH);
       lightNumber(toDisplay % 10);
        toDisplay /= 10;
      break;
    }
   
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
     digitalWrite(segDP, HIGH);
}
} 



//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  // all segment are ON
  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  
  // degree symbol made by niq_ro
  case 11:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  // C letter made by niq_ro
  case 12:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  
 // "o mic" letter made by niq_ro
  case 13:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;
    
 // "rotated 3" made by niq_ro
  case 33:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;
 
 // "rotated 1" made by niq_ro
  case 31:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;
    
  // "rotated 4" made by niq_ro
  case 34:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;
    
  }

 
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits){
  // utility function for clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}
   
   Cam atat... pentru moment.

19.11.2013
   In unele cazuri precizia lasa de dorit, pe unele placi aparand erori de 2-3 minute la 24 de ore, datorita cristaleor de cuart.