Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Se incluye la libreria FrequencyTimer2
- #include <FrequencyTimer2.h>
- //matrix 5x5
- //se declara la variable temCol de tipo entero inicializada en 5
- int temCol = 5;
- //se declara la variable temFil de tipo entero inicializada en 5
- int temFil = 5;
- //se definen las matrices de letras [A-Z]
- #define A { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1} \
- }
- #define B { \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 0} \
- }
- #define C { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 1} \
- }
- #define D { \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 0} \
- }
- #define E { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 1} \
- }
- #define F { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0} \
- }
- #define G { \
- {1, 0, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1} \
- }
- #define H { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1} \
- }
- #define I { \
- {1, 1, 1, 1, 1}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {1, 1, 1, 1, 1} \
- }
- #define J { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {1, 1, 1, 0, 0} \
- }
- #define K { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 1, 0}, \
- {1, 1, 1, 0, 0}, \
- {1, 0, 0, 1, 0}, \
- {1, 0, 0, 0, 1} \
- }
- #define L { \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0}, \
- {1, 1, 1, 1, 1} \
- }
- #define M { \
- {1, 1, 0, 1, 1}, \
- {1, 0, 1, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1} \
- }
- #define N { \
- {1, 0, 0, 0, 1}, \
- {1, 1, 0, 0, 1}, \
- {1, 0, 1, 0, 1}, \
- {1, 0, 0, 1, 1}, \
- {1, 0, 0, 0, 1} \
- }
- #define O { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1} \
- }
- #define P { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {1, 0, 0, 0, 0} \
- }
- #define Q { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 1, 1}, \
- {1, 1, 1, 1, 1} \
- }
- #define R { \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 0}, \
- {1, 0, 0, 1, 0}, \
- {1, 0, 0, 0, 1} \
- }
- #define S { \
- {0, 1, 1, 1, 1}, \
- {1, 0, 0, 0, 0}, \
- {0, 1, 1, 1, 0}, \
- {0, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 0} \
- }
- #define T { \
- {1, 1, 1, 1, 1}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0} \
- }
- #define U { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 1, 1, 1, 1} \
- }
- #define V { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {0, 1, 0, 1, 0}, \
- {0, 0, 1, 0, 0} \
- }
- #define W { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {1, 0, 1, 0, 1}, \
- {1, 1, 0, 1, 1}, \
- {1, 0, 0, 0, 1} \
- }
- #define X { \
- {1, 0, 0, 0, 1}, \
- {0, 1, 0, 1, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 1, 0, 1, 0}, \
- {1, 0, 0, 0, 1} \
- }
- #define Y { \
- {1, 0, 0, 0, 1}, \
- {1, 0, 0, 0, 1}, \
- {0, 1, 1, 1, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 0, 1, 0, 0} \
- }
- #define Z { \
- {1, 1, 1, 1, 1}, \
- {1, 0, 0, 1, 0}, \
- {0, 0, 1, 0, 0}, \
- {0, 1, 0, 0, 1}, \
- {1, 1, 1, 1, 1} \
- }
- #define blanco { \
- {0, 0, 0, 0, 0}, \
- {0, 0, 0, 0, 0}, \
- {0, 0, 0, 0, 0}, \
- {0, 0, 0, 0, 0}, \
- {0, 0, 0, 0, 0} \
- }
- //se declara la variable col2 de tipo intero enicializada en 0
- int col2 = 0;
- //se declara la variable tiempoEspera de tipo entero inicializada en 150
- int tiempoEspera = 150;
- //se declara la variable numLetras de tipo entero inicializada en 27
- const int numLetras = 27;
- //se declara la variable letras de tipo matrix de entero
- int letras [numLetras][5][5] = {
- A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,blanco
- };
- //matrix 5x8
- //se declara la variable numCol de tipo entero inicializada en 5
- const int numCol = 5;
- //se declara la variable numFil de tipo entero inicializada en 8
- const int numFil = 8;
- //se declara la variable matrixLeds de tipo matrix de entero
- int matrixLeds[numFil][numCol];
- //filas
- //se declara la variable constante fil de tipo vector de entero
- const int fil[numFil] = {
- 10,14,9,12,2,8,3,6};
- //columnas
- //se declara la variable constante col de tipo vector de entero inicializada en 5
- const int col[numCol] = {
- 13,4,5,11,7};
- void setup(){
- for(int i = 0; i < numFil; i++) {
- //pines de salida
- pinMode(fil[i], OUTPUT);
- //Se apaga el led,
- digitalWrite(fil[i],LOW);
- }
- for(int i = 0; i < numCol; i++) {
- //pines de salida
- pinMode(col[i], OUTPUT);
- //Se apaga el led,
- digitalWrite(col[i],LOW);
- }
- //comunicacion serial a 9600bps
- Serial.begin(9600);
- FrequencyTimer2::disable();
- FrequencyTimer2::setPeriod(2000);
- FrequencyTimer2::setOnOverflow(display);
- }
- 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);
- //cargamos el caracter en la matrix matrixLeds
- //y movemos cada pixel de posicion
- moveCharater(caracterMayuscula-65);
- } else
- //si hay un espacio
- if(dato == 32){
- moveCharater(numLetras-1);
- }
- } else {
- moveCharater(numLetras-1);
- }
- }
- void obtenerCaracter(int posicionCaracter){
- int posicion = numFil - temCol;
- for(int j = 0; j < temFil; j++) {
- for(int i = 0; i < temCol; i++) {
- matrixLeds[i+posicion][temCol-1-j] = letras[posicionCaracter][j][i];
- }
- }
- }
- void siguinteCaracter(int posicionCaracter, int temFila){
- int matrixTem[temFil][temCol];
- for(int i = 0; i < temFil; i++) {
- for(int j = 0; j < temCol; j++) {
- matrixTem[j][4-i] = letras[posicionCaracter][i][j];
- }
- }
- for (int j = 0; j < numCol; j++){
- matrixLeds[numFil-1][j] = matrixTem[temFila][j];
- }
- }
- void moveCharater(int posicionCaracter){
- int temFila = 0;
- do{
- for(int i = 0; i < numCol; i++) {
- for(int j = 0; j < numFil-1; j++) {
- matrixLeds[j][i] = matrixLeds[j+1][i];
- }
- }
- siguinteCaracter(posicionCaracter, temFila);
- delay(tiempoEspera);
- temFila++;
- } while(temFila < numFil);
- }
- void display(){
- digitalWrite(col[col2], HIGH);
- col2++;
- if (col2 == 5) {
- col2 = 0;
- }
- for (int row2 = 0; row2 < 8; row2++) {
- if (matrixLeds[row2][col2] == 1) {
- digitalWrite(fil[row2], HIGH);
- }
- else {
- digitalWrite(fil[row2], LOW);
- }
- }
- digitalWrite(col[col2], LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement