// Definindo variáveis
#define LED_A 2
#define LED_B 3
#define LED_C 4
#define LED_D 6
#define LED_E 7
#define LED_F 9
#define LED_G 8
// Delay entre letras (ms)
const int tempo=500;
void setup(){
pinMode(LED_A,OUTPUT);
pinMode(LED_B,OUTPUT);
pinMode(LED_C,OUTPUT);
pinMode(LED_D,OUTPUT);
pinMode(LED_E,OUTPUT);
pinMode(LED_F,OUTPUT);
pinMode(LED_G,OUTPUT);
}
void setDisplay(bool a, bool b, bool c, bool d, bool e, bool f, bool g){
digitalWrite(LED_A, a);
digitalWrite(LED_B, b);
digitalWrite(LED_C, c);
digitalWrite(LED_D, d);
digitalWrite(LED_E, e);
digitalWrite(LED_F, f);
digitalWrite(LED_G, g);
}
void setDisplay(char c){
setDisplay(0,0,0,0,0,0,0); //apaga tudo
// a b c d e f g
if (c == '0') { setDisplay(1,1,1,1,1,1,0); }
if (c == '1') { setDisplay(0,1,1,0,0,0,0); }
if (c == '2') { setDisplay(1,1,0,1,1,0,1); }
if (c == '3') { setDisplay(1,1,1,1,0,0,1); }
if (c == '4') { setDisplay(0,1,1,0,0,1,1); }
if (c == '5') { setDisplay(1,0,1,1,0,1,1); }
if (c == '6') { setDisplay(1,0,1,1,1,1,1); }
if (c == '7') { setDisplay(1,1,1,0,0,0,0); }
if (c == '8') { setDisplay(1,1,1,1,1,1,1); }
if (c == '9') { setDisplay(1,1,1,1,0,1,1); }
if (c == 'a' || c == 'A') { setDisplay(1,1,1,0,1,1,1); }
if (c == 'r' || c == 'R') { setDisplay(0,0,0,0,1,0,1); }
if (c == 'd' || c == 'D') { setDisplay(0,1,1,1,1,0,1); }
if (c == 'u' || c == 'U') { setDisplay(0,1,1,1,1,1,0); }
if (c == 'i' || c == 'I') { setDisplay(0,1,1,0,0,0,0); }
if (c == 'n' || c == 'N') { setDisplay(0,0,1,0,1,0,1); }
if (c == 'o' || c == 'O') { setDisplay(1,1,1,1,1,1,0); }
//fazer para os demais caracteres!!!
}
void showDisplayChar(char c, int timeOn, int timeOff, int atraso){
long resto = (millis()-atraso+100000) % (timeOn + timeOff);
if (resto < timeOn) { setDisplay(c); }
}
void showDisplayString(String s, int timeOn){
for (int i=0; i< s.length();i++){
showDisplayChar(s[i], timeOn, timeOn * s.length()-timeOn, (i-1)*timeOn );
}
}
void loop(){
showDisplayString("0123456789 ARDUINO ", tempo);
}
Inscreva-se no meu canal do youtube para ver mais vídeos como esse!