Código
O código Arduino
Use este código para executar o cronômetro de contagem regressiva // número do pino de 7 segmentos - luz de 7 segmentos - número do pino do Arduino // pino 11 - A =12 // pino 7 - B =10 // pino 4 - C =8 / / pino 2 - D =7 // pino 1 - E =6 // pino 10 - F =11 // pino 5 - G =9 // pino 3 é decimal / * 12 11 10 9 8 7 | | | | | | A --- F | | B | G | --- E | | C | | ---. dez D | | | | | | 1 2 3 4 5 6 * /// pino 12 - primeiro dígito =1 // pino 9 - segundo dígito =2 // pino 8 - terceiro dígito =3 // pino 6 quarto dígito =4const int a =12; const int b =10; const int c =8; const int d =7; const int e =6; const int f =11; const int g =9; int p =0; int startStopReset =13; const int d1 =1; const int d2 =2; const int d3 =3; const int d4 =4; longo n =60000; // hora de início -> PODE ALTERAR A QUALQUER HORA QUE VOCÊ QUISERint x =100; int del =55; // valor de atraso void setup () {pinMode (d1, OUTPUT); pinMode (d2, SAÍDA); pinMode (d3, SAÍDA); pinMode (d4, SAÍDA); pinMode (a, OUTPUT); pinMode (b, OUTPUT); pinMode (c, OUTPUT); pinMode (d, SAÍDA); pinMode (e, SAÍDA); pinMode (f, OUTPUT); pinMode (g, OUTPUT); pinMode (p, OUTPUT); pinMode (startStopReset, INPUT); digitalWrite (startStopReset, HIGH); } void loop () {digitalWrite (p, HIGH); clearLEDs (); pickDigit (1); pickNumber ((n / x / 1000)% 10); delayMicroseconds (del); clearLEDs (); pickDigit (2); pickNumber ((n / x / 100)% 10); delayMicroseconds (del); clearLEDs (); pickDigit (3); dispDec (3); pickNumber ((n / x / 10)% 10); delayMicroseconds (del); clearLEDs (); pickDigit (4); pickNumber (n / x% 10); delayMicroseconds (del); n--; // 'n ++' para cronômetro if (digitalRead (13) ==LOW) {n =60000; // hora de reinicialização -> MUDE PARA QUALQUER HORA QUE VOCÊ CONFIGURAR ORIGONALMENTE (hora de início)}} void pickDigit (int x) // altera o dígito {digitalWrite (d1, HIGH); digitalWrite (d2, HIGH); digitalWrite (d3, HIGH); digitalWrite (d4, HIGH); switch (x) {caso 1:digitalWrite (d1, LOW); pausa; caso 2:digitalWrite (d2, LOW); pausa; caso 3:digitalWrite (d3, LOW); digitalWrite (p, HIGH); // nova pausa; padrão:digitalWrite (d4, LOW); pausa; }} void pickNumber (int x) // altera o valor do número {switch (x) {default:zero (); pausa; caso 1:um (); pausa; caso 2:dois (); pausa; caso 3:três (); pausa; caso 4:quatro (); pausa; caso 5:cinco (); pausa; caso 6:seis (); pausa; caso 7:sete (); pausa; caso 8:oito (); pausa; caso 9:nove (); pausa; }} void dispDec (int x) {digitalWrite (p, LOW);} void clearLEDs () {digitalWrite (a, LOW); digitalWrite (b, LOW); digitalWrite (c, LOW); digitalWrite (d, LOW); digitalWrite (e, LOW); digitalWrite (f, LOW); digitalWrite (g, LOW); digitalWrite (p, LOW);} void zero () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, HIGH); digitalWrite (f, HIGH); digitalWrite (g, LOW);} void one () {digitalWrite (a, LOW); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, LOW); digitalWrite (e, LOW); digitalWrite (f, LOW); digitalWrite (g, LOW);} void two () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, LOW); digitalWrite (d, HIGH); digitalWrite (e, HIGH); digitalWrite (f, LOW); digitalWrite (g, HIGH);} void three () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, LOW); digitalWrite (f, LOW); digitalWrite (g, HIGH);} void four () {digitalWrite (a, LOW); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, LOW); digitalWrite (e, LOW); digitalWrite (f, HIGH); digitalWrite (g, HIGH);} void five () {digitalWrite (a, HIGH); digitalWrite (b, LOW); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, LOW); digitalWrite (f, HIGH); digitalWrite (g, HIGH);} void six () {digitalWrite (a, HIGH); digitalWrite (b, LOW); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, HIGH); digitalWrite (f, HIGH); digitalWrite (g, HIGH);} void seven () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, LOW); digitalWrite (e, LOW); digitalWrite (f, LOW); digitalWrite (g, LOW);} void eight () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, HIGH); digitalWrite (f, HIGH); digitalWrite (g, HIGH);} void nine () {digitalWrite (a, HIGH); digitalWrite (b, HIGH); digitalWrite (c, HIGH); digitalWrite (d, HIGH); digitalWrite (e, LOW); digitalWrite (f, HIGH); digitalWrite (g, HIGH);}