Paso 3: Kod
int hora = 9;
int minutos = 29;
int firstpin = 6;
int secondpin = 7;
int thirdpin = 8;
int fourthpin = 9;
int prevmillis;
intervalo de int = 50; int segundos;
int firstanode = 2;
int secondanode = 3;
int thirdanode = 4; int fourthanode = 5;
void setup() {}
pinMode (7, salida);
pinMode (2, salida);
pinMode (3, salida);
pinMode (4, salida);
pinMode (5, salida);
pinMode (6, salida);
pinMode (7, salida);
pinMode (8, salida);
pinMode (9, salida);
pinMode (A0, INPUT_PULLUP);
pinMode (A1, INPUT_PULLUP);
pinMode (A2, INPUT_PULLUP);
pinMode (A3, INPUT_PULLUP);
Serial.Begin(9600); }
void loop() {}
Si ((millis()-prevmillis) > intervalo) {prevmillis = millis(); segundo ++;
Si (segundo == 60) {segundo = 0; minuto ++;}
Si (minutos == 60) {minuto = 0; hora ++;}
if(hour==24) {hora = 0;}} Si intervalo
Si Cave Lee (a0) == baja //minute++ //id digr leer a1 == baja //minute--
DisplayTime (hora, minuto); } //loop
Displatbars (temp, hum);
Knappar Kolla, kolla därefter
void Displaytime (int hour_, int minute_) {}
digit2 int = hour_ % 10;
entals siffran hora
int digit1 = hour_ - digit2 * 10;
tiotalsiffran hora
int digit4 = minute_ % 10;
entals siffran minutos
int digit3 = minute_ - digit4 * 10;
tiotalsiffran minutos
Serial.Print(digit1);
Serial.Print(digit2);
Serial.Print(digit3);
Serial.println(digit4);
digitalWrite (firstanode, HIGH);
BCDwrite(digit1);
Delay(20); digitalWrite (2, bajo);
digitalWrite (secondanode, HIGH);
BCDwrite(digit2);
Delay(20);
digitalWrite (3, bajo);
digitalWrite (thirdanode, HIGH);
BCDwrite(digit3);
Delay(20);
digitalWrite (4, bajo);
digitalWrite (fourthanode, HIGH);
BCDwrite(digit4);
Delay(20);
digitalWrite (5, bajo); }
void BCDwrite (int número) //0-9
{
digitalWrite (firstpin, bitRead (número, 0));
digitalWrite (secondpin, bitRead (número 1));
digitalWrite (thirdpin, bitRead (número 2));
digitalWrite (fourthpin, bitRead (número 3)); }