/*
Example "Protest scroller" for 8x32 WS2812 "NeoPixel Display
Assumes you are running a standard Arduino ATMega328 compatible board
*/
#include <Wire.h>
#include <Adafruit_NeoMatrix.h>
// RTC module at address 0x68
#define DS1307_ADDRESS 0x68
#define PIN 3
// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255), matrix.Color(255, 255, 0)
};
uint8_t clear = 0x00;
void setup() {
//Serial.begin(115200);
Wire.begin();
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(40);
matrix.setTextColor(colors[0]);
}
int x = matrix.width();
int pass = 0;
void loop() {
// Read the values (date and time) of the DS1307 module
Wire.beginTransmission(DS1307_ADDRESS);
Wire.write(clear);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 0x07);
uint8_t seconds = bcdToDec(Wire.read());
uint8_t minutes = bcdToDec(Wire.read());
uint8_t hours = bcdToDec(Wire.read() & 0xff);
uint8_t wday = bcdToDec(Wire.read());
uint8_t mday = bcdToDec(Wire.read());
uint8_t month = bcdToDec(Wire.read());
uint8_t year = bcdToDec(Wire.read());
String dt = "";
// Adds 0 (clear) if the time is less than 10
//if (hours < 10)
// dt.concat("0");
dt.concat(hours);
if (seconds & 1)
dt.concat(":");
else
dt.concat(" ");
// Adds 0 (clear) if minutes are less than 10
if (minutes < 10)
dt.concat("0");
dt.concat(minutes);
if (seconds & 1)
dt.concat(":");
else
dt.concat(" ");
// Seconds
if (seconds < 10)
dt.concat("0");
dt.concat(seconds);
// Show the day of the week
switch(wday)
{
case 1:dt.concat(" Sun ");
break;
case 2:dt.concat(" Mon ");
break;
case 3:dt.concat(" Tue ");
break;
case 4:dt.concat(" Wed ");
break;
case 5:dt.concat(" Thu ");
break;
case 6:dt.concat(" Fri ");
break;
case 7:dt.concat(" Sat ");
}
// Adds 0 (clear) if day of the month is less than 10
if (mday < 10)
dt.concat("0");
dt.concat(mday);
dt.concat("-");
// Add 0 (clear) if month is less than 10
if (month < 10)
dt.concat("0");
dt.concat(month);
dt.concat("-");
dt.concat(year);
matrix.fillScreen(0); //Turn off all the LEDs
matrix.setCursor(x, 1);
matrix.print(dt);
if (--x < -119) {
x = matrix.width();
if (++pass >= 4)
pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(100);
}
uint8_t decToBcd(uint8_t value)
{
// Converts the decimal number to BCD
return ((value / 10 * 16) + (value % 10));
}
uint8_t bcdToDec(uint8_t value)
{
// Converts from BCD to decimal
return ((value / 16 * 10) + (value % 16));
}
/*
#include "elapsedMillis.h"
#include "Adafruit_NeoPixel.h"
#include "Wire.h" //libreria per interfacciare i2c e rtc
#include "RTClib.h"
RTC_DS3231 rtc; //nome rtc
#define NUM_LEDS 256
#define DATA_PIN 3
Adafruit_NeoPixel leds(NUM_LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800);
#define Set 10
#define Up 11
#define Down 12
byte PannelloYX[8][32] = {{0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 , 9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31},
{63,62 ,61 ,60 ,59 ,58 ,57 ,56 ,55 ,54 ,53 ,52 ,51 ,50 ,49 ,48 ,47 ,46 ,45 ,44 ,43 ,42 ,41 ,40 ,39 ,38 ,37 ,36 ,35 ,34 ,33 ,32},
{64,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,78 ,80 ,81 ,82 ,83 ,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95},
{127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99 ,98 ,97 ,96},
{128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159},
{191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160},
{192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223},
{255,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224}};
byte Cifre[10][40] = {{0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0 }, //0
{0,0,1,0,0,
0,1,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,1,1,1,0 }, //1
{0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
0,0,0,0,1,
0,0,0,1,0,
0,0,1,0,0,
0,1,0,0,0,
1,1,1,1,1 }, //2
{0,1,1,1,0,
1,0,0,0,1,
0,0,0,0,1,
0,0,1,1,0,
0,0,0,0,1,
0,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0 }, //3
{0,0,0,1,0,
0,0,1,1,0,
0,1,0,1,0,
1,0,0,1,0,
1,1,1,1,1,
0,0,0,1,0,
0,0,0,1,0,
0,0,0,1,0 }, //4
{1,1,1,1,1,
1,0,0,0,0,
1,0,0,0,0,
1,1,1,1,0,
0,0,0,0,1,
0,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0 }, //5
{0,1,1,1,0,
1,0,0,0,0,
1,0,0,0,0,
1,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0 }, //6
{1,1,1,1,1,
0,0,0,0,1,
0,0,0,1,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0 }, //7
{0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0 }, //8
{0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,1,
0,0,0,0,1,
0,0,0,0,1,
0,0,0,0,1,
0,1,1,1,0 } //9
};
uint8_t pos_digit[4]= {0,7,19,26};
uint8_t Digitos[4] = {};
boolean conta = false;
uint8_t ciclo = 0;
uint16_t Tot_Lum = 0;
uint8_t Ciclo_Lum = 0;
uint8_t r = 100;
uint8_t g = 100;
uint8_t b = 100;
bool DST = false;
elapsedSeconds Ora_LED;
elapsedMillis Lamp_LED;
///////////////////////////////////////////////
// SUB..
///////////////////////////////////////////////
void legge_ore(void)
{
DateTime now = rtc.now(); //creo istanza ora/data
uint8_t Hh = now.hour();
uint8_t Mm = now.minute();
uint8_t Ss = now.second();
// La data e ora devono essere esatte per cambio ora
if (now.dayOfTheWeek() == 0 && now.month() == 3 && now.day() >= 25 && now.day() <= 31 && Hh == 2 && Mm == 0 && Ss < 10)
{
rtc.adjust(DateTime(now.year(), now.month(), now.day(), Hh+1, Mm , Ss));
DST = false;
}
if (!DST)
{
if(now.dayOfTheWeek() == 0 && now.month() == 10 && now.day() >= 25 && now.day() <= 31 && Hh == 3 && Mm == 0)
{
rtc.adjust(DateTime(now.year(), now.month(), now.day(), Hh-1, Mm , Ss));
DST = true;
}
}
ciclo = 60-Ss;
uint8_t ora1 = (Hh % 100) / 10 ;
uint8_t ora2 = Hh % 10 ;
uint8_t min1 = (Mm % 100) / 10 ;
uint8_t min2 = Mm %10 ;
stampa_ore_scorre(ora1,ora2,min1,min2); ///stampa_ore();
Digitos[0] = ora1 ;
Digitos[1] = ora2 ;
Digitos[2] = min1 ;
Digitos[3] = min2 ;
}
//=============================================================================================================================
void Colore_Led(void)
{
// colore pannello rgb
if( Digitos[0]==0 and Digitos[1]>=0 or Digitos[0]==0 and Digitos[1] < 7)
{ r = 0; g = 0; b = 100;}
if( Digitos[0]==0 and Digitos[1]>=7 or Digitos[0]==1 and Digitos[1] < 9)
{ r = 100; g = 100; b = 100;}
if( Digitos[0]==1 and Digitos[1]>=9 or Digitos[0]==2 and Digitos[1] <=3)
{ r = 100; g = 0; b = 0;}
}
//=============================================================================================================================
void luminosita(void) /// controllo luninosità
{
Tot_Lum += analogRead(A0);
Ciclo_Lum++;
if (Ciclo_Lum == 5)
{
uint16_t Lum = Tot_Lum/Ciclo_Lum;
uint8_t lux = Lum/7;
if (lux < 2)
lux = 2;
if (lux > 255)
lux = 255;
leds.setBrightness(lux);
Colore_Led();
stampa_ore();
Ciclo_Lum = 0;
Tot_Lum = 0;
}
}
//=============================================================================================================================
void lampeggio_led(void)
{
conta = !conta;
if (conta)
{
leds.setPixelColor(79, 0, 0, 0);
leds.setPixelColor(176, 0, 0, 0);
leds.show();
luminosita();
}
else
{
leds.setPixelColor(79, r, g, b);
leds.setPixelColor(176, r, g, b);
leds.show();
}
}
//=============================================================================================================================
void stampa_ore(void)
{
uint8_t num_pixel = 0;
leds.clear();
for(uint8_t d=0; d<4; d++)
{
if (pos_digit[d] > 0 || Digitos[d] > 0) // primo numero delle ore non deve essere ZERO
{
uint8_t numero = Digitos[d];
uint8_t cc = 0;
uint8_t pixc = 0;
while (cc < 8)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc][pos_digit[d] + s]; // posizione led
if (Cifre[numero][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
s++;
pixc++;
}
cc++;
}
}
}
leds.show();
}
//=============================================================================================================================
void stampa_ore_scorre(uint8_t Sn1,uint8_t Sn2,uint8_t Sn3,uint8_t Sn4)
{
uint8_t num_pixel = 0;
uint8_t set_n = 35;
uint8_t pixc = 0;
uint8_t n_righe = 8;
uint8_t n_righe2 = 1;
uint8_t cc = 1;
uint8_t cc2 = 0;
uint8_t RigaY = 0;
for(uint8_t cicli=0; cicli<12; cicli++)
{
///// ORE 1 ///////////////////////
if( Sn1 != Digitos[0])
{
if(cicli<8)
{
for(uint8_t n=0; n<5; n++)
{
num_pixel = PannelloYX[cicli][pos_digit[0]+n];
leds.setPixelColor(num_pixel,0,0,0);
}
}
cc=1;pixc = 0;
while (cc < n_righe)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc+cc2][pos_digit[0] + s]; // posizione led
if (Cifre[Digitos[0]][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
cc++;
}
if(cicli>3)
{
RigaY = 0; pixc = 0;
while (RigaY < n_righe2)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[RigaY][pos_digit[0] + s]; // posizione led
if (Cifre[Sn1][set_n+pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
RigaY++;
}
}
}
//////////////////////////////////////////////////////
// ORE 2 ///////////////////////////
if( Sn2 != Digitos[1])
{
if(cicli<8)
{
for(uint8_t n=0; n<5; n++)
{
num_pixel = PannelloYX[cicli][pos_digit[1]+n];
leds.setPixelColor(num_pixel,0,0,0);
}
}
cc=1;pixc = 0;
while (cc < n_righe)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc+cc2][pos_digit[1] + s]; // posizione led
if (Cifre[Digitos[1]][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
cc++;
}
if(cicli>3)
{
RigaY = 0; pixc = 0;
while (RigaY < n_righe2)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[RigaY][pos_digit[1] + s]; // posizione led
if (Cifre[Sn2][set_n+pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
RigaY++;
}
}
}
//////////////////////////////////////////////////////////////
// MINUTI 1 ///////////////////////////
if( Sn3 != Digitos[2])
{
if(cicli<8)
{
for(uint8_t n=0; n<5; n++)
{
num_pixel = PannelloYX[cicli][pos_digit[2]+n];
leds.setPixelColor(num_pixel,0,0,0);
}
}
cc=1;pixc = 0;
while (cc < n_righe)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc+cc2][pos_digit[2] + s]; // posizione led
if (Cifre[Digitos[2]][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
cc++;
}
if(cicli>3)
{
RigaY = 0; pixc = 0;
while (RigaY < n_righe2)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[RigaY][pos_digit[2] + s]; // posizione led
if (Cifre[Sn3][set_n+pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
RigaY++;
}
}
}
///////////////////////////////////////////////////////////////////
// MINUTI 2 ///////////////////////////
if( Sn4 != Digitos[3])
{
if(cicli<8)
{
for(uint8_t n=0; n<5; n++)
{
num_pixel = PannelloYX[cicli][pos_digit[3]+n];
leds.setPixelColor(num_pixel,0,0,0);
}
}
cc=1;pixc = 0;
while (cc < n_righe)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc+cc2][pos_digit[3] + s]; // posizione led
if (Cifre[Digitos[3]][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
cc++;
}
if(cicli>3)
{
RigaY = 0; pixc = 0;
while (RigaY < n_righe2)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[RigaY][pos_digit[3] + s]; // posizione led
if (Cifre[Sn4][set_n+pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,r, g, b);} //pix acceso
else
{leds.setPixelColor(num_pixel,0,0,0);} //pix spento
pixc++;
s++;
}
RigaY++;
}
}
}
if(cicli<8)
{
n_righe--;
cc2++;
}
if(cicli>3)
{
n_righe2++;
set_n = set_n -5;
}
leds.show();
delay(100);
}
}
//=========================================================
void MENU_setup()
{
elapsedSeconds Time_ESC;
uint8_t Tempo = 20;
DateTime now = rtc.now();
uint16_t Aa = now.year();
uint8_t Ms = now.month();
uint8_t Dd = now.day();
uint8_t Hh = now.hour();
uint8_t Mm = now.minute();
uint8_t Ss = now.second();
if (Aa < 2020)
{ Aa = 2020; }
Setup_ore(Dd); // giorno
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
if(Dd == 31)
Dd = 1;
else
Dd=Dd+1;
Setup_ore(Dd);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
if(Dd == 1)
Dd = 31;
else
Dd=Dd-1;
Setup_ore(Dd);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
break;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
Setup_ore(Ms); // mese
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
if(Ms == 12)
Ms = 1;
else
Ms=Ms+1;
Setup_ore(Ms);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
if(Ms == 1)
Ms = 12;
else
Ms=Ms-1;
Setup_ore(Ms);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
break;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
Setup_ore(Aa); // anno
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
Aa=Aa+1;
Setup_ore(Aa);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
Aa=Aa-1;
Setup_ore(Aa);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
break;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
Setup_ore(Hh); // ore
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
if(Hh == 23)
Hh = 0;
else
Hh=Hh+1;
Setup_ore(Hh);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
if(Hh == 0)
Hh = 23;
else
Hh=Hh-1;
Setup_ore(Hh);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
break;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
Setup_ore(Mm); // minuti
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
if(Mm == 59)
Mm = 0;
else
Mm=Mm+1;
Setup_ore(Mm);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
if(Mm == 0)
Mm = 59;
else
Mm=Mm-1;
Setup_ore(Mm);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
break;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
Setup_ore(Ss); // secondi
while (1)
{
delay(400);
if (digitalRead(Up) == LOW) // Up
{
if(Ss == 59)
Ss = 0;
else
Ss=Ss+1;
Setup_ore(Ss);
Time_ESC = 0;
}
if (digitalRead(Down) == LOW) //Down
{
if(Ss == 0)
Ss = 59;
else
Ss=Ss-1;
Setup_ore(Ss);
Time_ESC = 0;
}
if (digitalRead(Set) == LOW) //Menu
{
rtc.adjust(DateTime(Aa,Ms,Dd,Hh,Mm,Ss));
leds.clear();leds.show();
delay(400);
return;
}
if (Time_ESC > Tempo) // secondi
{
Time_ESC = 0;return;
}
}
}
//=============================================================================================================================
void Setup_ore(uint16_t numero)
{
uint8_t num_pixel = 0;
uint8_t Cifra[2] = {};
leds.clear();
uint8_t ora1 = (numero % 100) / 10 ;
uint8_t ora2 = numero % 10 ;
Cifra[0] = ora1 ;
Cifra[1] = ora2 ;
for(uint8_t d=0; d<2; d++)
{
uint8_t num = Cifra[d];
uint8_t cc = 0;
uint8_t pixc = 0;
while (cc < 8)
{
uint8_t s = 0;
while (s < 5)
{
num_pixel = PannelloYX[cc][pos_digit[d+2] + s]; // posizione led
if (Cifre[num][pixc] == 1) // [0 a 9] --- [0 a 39]
{leds.setPixelColor(num_pixel,100, 100, 0);} //pix acceso
s++;
pixc++;
}
cc++;
}
}
leds.show();
}
//==========================================================================================================================
//==========================================================================================================================
//==========================================================================================================================
// SETUP SETUP SETUP SETUP SETUP SETUP SETUP
//==========================================================================================================================
void setup()
{
pinMode(DATA_PIN, OUTPUT);
pinMode(Set, INPUT_PULLUP ); // 10
pinMode(Up, INPUT_PULLUP ); // 11
pinMode(Down, INPUT_PULLUP ); // 12
pinMode(A0, INPUT);
Wire.begin();
rtc.begin();
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // CARICA ora del PC
// rtc.adjust(DateTime(2021,05,18,9,59,40));
leds.begin();
leds.setBrightness(5);
leds.clear();
leds.show();
// leds.fill(leds.Color(0,255,0),0, 5);
// Serial.begin(115200);
//Serial.print(sensorValue); Serial.print("----");
}
/// /// R G B
/////// Rosso Verde Blu
//=============================================================================================================================
// LOOP LOOP LOOP LOOP LOOP LOOP
//=============================================================================================================================
void loop()
{
/*
if (Serial.available() > 0)
{
char rx = Serial.read();
if (rx == '8')
{
DateTime now = rtc.now();
int Aa = now.year();
int Ms = now.month();
int Dd = now.day();
int Hh = now.hour();
int Mm = now.minute();
int Ss = now.second();
if(Ss == 59)
Ss = 0;
else
Ss=Ss+1;
Serial.println(Ss);
rtc.adjust(DateTime(Aa,Ms,Dd,Hh,Mm,Ss));
// rtc.adjust(DateTime(now+TimeSpan(0,0,1,0))); // +++ minuti
}
if (rx == '2')
{
DateTime now = rtc.now();
int Aa = now.year();
int Ms = now.month();
int Dd = now.day();
int Hh = now.hour();
int Mm = now.minute();
int Ss = now.second();
if(Ss == 0)
Ss = 59;
else
Ss=Ss-1;
Serial.println(Ss);
rtc.adjust(DateTime(Aa,Ms,Dd,Hh,Mm,Ss));
// rtc.adjust(DateTime(now-TimeSpan(0,0,1,0))); //--- minuti
}
if (rx == '0')
{
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
*/
/*
/// ////////////////////////////////////////
if (digitalRead(Set) == LOW) //Menu
{
MENU_setup();
delay(400);
}
if (Ora_LED > ciclo) // secondi
{
legge_ore();
Ora_LED = 0;
}
if (Lamp_LED > 500) // Millisecondi
{
lampeggio_led();
Lamp_LED =0;
}
}
*/
//=========================================================================================================================================================================================
// F I N E F I N E F I N E F I N E F I N E F I N E
//=========================================================================================================================================================================================