Étape 3: Le programme complet
#include < Colorduino.h >
#include < Wire.h >
#include < Time.h >
#include < DS1307RTC.h >
int R = 30 ;
int B = 40 ;
int G = 50 ;
int rang = 0 ;
g int = 0 ;
int GKB = 0 ;
incrément int = 12 ;
int initalG = 0 ;
void setup()
{
Colorduino.Init() ;
unsigned char whiteBalVal [3] = {28,60,44}; //RGB
Colorduino.SetWhiteBal(whiteBalVal) ;
}
Sub binaryOutput(int number)
{
Si (nombre > = 10)
{
int dizaines = nombre / 10 ;
les unités int = nombre - (RTE * 10) ;
setBinary(units,ROW) ;
LIGNE = LIGNE + 1 ;
setBinary(tens,ROW) ;
}
d’autre
{
des dizaines d’int = 0 ;
les unités int = nombre ;
setBinary(units,ROW) ;
LIGNE = LIGNE + 1 ;
setBinary(tens,ROW) ;
}
}
setBinary nulle (valeur int, int whichRow)
{
LIGNE = whichRow ;
int XYZ = 8 ;
int COL = 3 ;
pour (int i = 0; j’ai 4 <; i ++)
{
getColor(g) ;
Si (valeur > = XYZ)
{
Colorduino.SetPixel(ROW,COL,R,G,B) ;
valeur = valeur - XYZ ;
}
d’autre
{
Colorduino.SetPixel(ROW,COL,0,0,0) ;
}
XYZ = XYZ / 2 ;
COL = COL - 1 ;
}
}
Sub getColor(int rainbow)
{
Si (arc-en-ciel < 255)
{
R = arc-en-ciel ;
B = 255 - arc-en-ciel ;
G = 0 ;
}
ElseIf (arc-en-ciel < 511)
{
arc en ciel = arc-en-ciel - 255 ;
R = 255 - arc-en-ciel ;
B = 0 ;
G = arc-en-ciel ;
}
d’autre
{
arc en ciel = arc-en-ciel - 510 ;
R = 0 ;
B = arc-en-ciel ;
G = 255 - arc-en-ciel ;
}
g = g + incrément ;
Si (g > (765 - incrémentation))
{
g = 0 ;
}
}
void loop()
{
tmElements_t tm ;
Si (RTC.read(tm))
{
initalG = g ;
binaryOutput (tm. Seconde) ;
LIGNE = LIGNE + 1 ;
binaryOutput (tm. Minute) ;
LIGNE = LIGNE + 1 ;
binaryOutput (tm. Heure) ;
LIGNE = 0 ;
Delay(6) ;
g = initalG + 1 ;
Si (g > (765 - incrémentation))
{
g = 0 ;
}
}
Colorduino.FlipPage() ;
}