#include <Sprite.h>
#include <Matrix.h>
int count = 0;
int x = 8;
int letra1 = 0;
int letra2 = 0;
int tiempoEspera = 0;
const int numChips = 1;
int DIN = 16; //1
int CLK = 17; //13
int LOAD = 18; //12
//DIN, CLK, LOAD, #chips
Matrix matrix = Matrix(DIN, CLK, LOAD, numChips);
void setup() {
pinMode(16,OUTPUT);
pinMode(17,OUTPUT);
pinMode(18,OUTPUT);
tiempoEspera = 150;
Serial.begin(9600);
}
void loop() {
if(Serial.available() > 0){
byte dato = Serial.read();
//si el dato esta entre A-Z o a-z
if((64 < dato && dato < 91) || (96 < dato && dato < 123)){
//pasamos a mayuscula el caracter
byte caracterMayuscula = toUpperCase(dato);
letra1 = caracterMayuscula-65;
mover();
}else {
//si hay espacio
if(dato == 32){
letra1 = 26;
mover();
}
}
}else{
letra1 = 26;
mover();
}
}
void mover(){
do{
delay(tiempoEspera);
count--;
x--;
pintar();
}while(x >= 0);
x = 8;
count = 6;
letra2 = letra1;
}
Sprite letras(int valor){
//creamos los sprite con 5 pixeles de ancho y 5 pixelex de alto
int _width = 5;
int _height = 5;
switch(valor){
case 0:
//A
return Sprite(_width, _height,
B10001, B10001, B11111, B10001, B11111
);
break;
case 1:
//B
return Sprite(5, 5,
B11110, B10001, B11110, B10001, B11110
);
break;
case 2:
//C
return Sprite(5, 5,
B11111, B10000, B10000, B10000, B11111
);
break;
case 3:
//D
return Sprite(5, 5,
B11110, B10001, B10001, B10001, B11110
);
break;
case 4:
//E
return Sprite(5, 5,
B11111, B10000, B11111, B10000, B11111
);
break;
case 5:
//F
return Sprite(5, 5,
B10000, B10000, B11110, B10000, B11110
);
break;
case 6:
//G
return Sprite(5, 5,
B11111, B10001, B11111, B10000, B11111
);
break;
case 7:
//H
return Sprite(5, 5,
B10001, B10001, B11111, B10001, B10001
);
break;
case 8:
//I
return Sprite(5, 5,
B11111, B00100, B00100, B00100, B11111
);
break;
case 9:
//J
return Sprite(5, 5,
B11100, B00100, B00100, B00100, B11111
);
break;
case 10:
//K
return Sprite(5, 5,
B10001, B10010, B11100, B10010, B10001
);
break;
case 11:
//L
return Sprite(5, 5,
B11111, B10000, B10000, B10000, B10000
);
break;
case 12:
//M
return Sprite(5, 5,
B10001, B10001, B10001, B10101, B11011
);
break;
case 13:
//N
return Sprite(5, 5,
B10001, B10011, B10101, B11001, B10001
);
break;
case 14:
//O
return Sprite(5, 5,
B11111, B10001, B10001, B10001, B11111
);
break;
case 15:
//P
return Sprite(5, 5,
B10000, B10000, B11110, B10001, B11110
);
break;
case 16:
//Q
return Sprite(5, 5,
B11111, B10011, B10001, B10001, B11111
);
break;
case 17:
//R
return Sprite(5, 5,
B10001, B10010, B11110, B10001, B11110
);
break;
case 18:
//S
return Sprite(5, 5,
B11110, B00001, B01110, B10000,B01110
);
break;
case 19:
//T
return Sprite(5, 5,
B00100, B00100, B00100, B00100, B11111
);
break;
case 20:
//U
return Sprite(5, 5,
B11111, B10001, B10001, B10001, B10001
);
break;
case 21:
//V
return Sprite(5, 5,
B00100, B01010, B10001, B10001, B10001
);
break;
case 22:
//W
return Sprite(5, 5,
B10001, B11011, B10101, B10001, B10001
);
break;
case 23:
//X
return Sprite(5, 5,
B10001, B01010, B00100, B01010, B10001
);
break;
case 24:
//Y
return Sprite(5, 5,
B00100, B00100, B01110, B10001, B10001
);
break;
case 25:
//Z
return Sprite(5, 5,
B11111, B01000, B00100, B00010, B11111
);
break;
case 26:
//Blanco
return Sprite(5, 5,
B00000, B00000, B00000, B00000, B00000
);
break;
}
}
void pintar(){
matrix.clear();
//se coloca el Sprite en pantalla
matrix.write(x, 0, letras(letra1));
if(count >= 0){
matrix.write(x - 8, 0, letras(letra2));
}
}