Stap 3: Het volledige programma
#include < Colorduino.h >
#include < Wire.h >
#include < Time.h >
#include < DS1307RTC.h >
int R = 30;
int B = 40;
int G = 50;
int rij = 0;
int g = 0;
int GKB = 0;
int toename = 12;
int initalG = 0;
VOID Setup
{
Colorduino.Init();
unsigned char whiteBalVal [3] = {28,60,44}; //RGB
Colorduino.SetWhiteBal(whiteBalVal);
}
VOID binaryOutput(int number)
{
Als (nummer > = 10)
{
int tientallen = nummer / 10;
int eenheden = aantal - (trans-Europese netwerken * 10);
setBinary(units,ROW);
RIJ = RIJ + 1;
setBinary(tens,ROW);
}
anders
{
int tientallen = 0;
int eenheden = nummer;
setBinary(units,ROW);
RIJ = RIJ + 1;
setBinary(tens,ROW);
}
}
VOID setBinary (int waarde, int whichRow)
{
RIJ = whichRow;
int XYZ = 8;
int COL = 3;
for (int i = 0; ik < 4; ik ++)
{
getColor(g);
Als (waarde > XYZ =)
{
Colorduino.SetPixel(ROW,COL,R,G,B);
waarde = waarde - XYZ;
}
anders
{
Colorduino.SetPixel(ROW,COL,0,0,0);
}
XYZ = XYZ / 2;
COL = COL - 1;
}
}
VOID getColor(int rainbow)
{
Als (regenboog < 255)
{
R = regenboog;
B = 255 - regenboog;
G = 0;
}
anders als (regenboog < 511)
{
regenboog = rainbow - 255;
R = 255 - regenboog;
B = 0;
G = regenboog;
}
anders
{
regenboog = rainbow - 510;
R = 0;
B = regenboog;
G = 255 - regenboog;
}
g = g + increment;
Als (g > (765 - increment))
{
g = 0;
}
}
void loop
{
tmElements_t tm;
Als (RTC.read(tm))
{
initalG = g;
binaryOutput (tm. Seconde);
RIJ = RIJ + 1;
binaryOutput (tm. Minuut);
RIJ = RIJ + 1;
binaryOutput (tm. Uur);
RIJ = 0;
delay(6);
g = initalG + 1;
Als (g > (765 - increment))
{
g = 0;
}
}
Colorduino.FlipPage();
}