Created
May 7, 2015 22:36
-
-
Save sabas1080/b9d0dbdbd652fe7c5a4e to your computer and use it in GitHub Desktop.
Generar letras con matriz de leds prueba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte P[] = { 0x02, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x40 }; | |
byte R[] = { 0x78, 0x44, 0x44, 0x78, 0x70, 0x58, 0x4C, 0x46 }; | |
byte O[] = { 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C }; | |
byte M[] = { 0x66, 0x7E, 0x5A, 0x42, 0x42, 0x42, 0x42, 0x42 }; | |
byte E[] = { 0x7C, 0x40, 0x40, 0x78, 0x78, 0x40, 0x40, 0x7C }; | |
byte T[] = { 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }; | |
byte C[] = { 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C }; | |
byte N[] = { 0x42, 0x62, 0x72, 0x5A, 0x4E, 0x46, 0x42, 0x42 }; | |
byte dot[]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06 }; | |
byte sp[]= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | |
void setup() // Prog_36_1 | |
{ for (int j=2; j<19; j++) | |
pinMode(j, OUTPUT); | |
Serial.begin(9600); | |
} | |
void SetChar(char p) | |
{ | |
Clear(); | |
for (int fil = 0; fil <8 ; fil++) | |
{ | |
digitalWrite( fil + 10 , LOW) ; // Activamos la fila para el barrido | |
//byte F = N[fil] ; | |
byte F = Selecciona( p, fil); | |
for (int col =7; col >= 0 ; col--) | |
{ | |
digitalWrite(8-col, LOW); //Bajamos la columna | |
bool b = GetBit(F, col) ; | |
if (b) | |
digitalWrite( 9 - col ,HIGH); //Levantamos la columna, con su pin | |
else | |
digitalWrite( 9 - col ,LOW); // Si 0, apagamos | |
} // Solo si b es 1 | |
digitalWrite( fil + 10 , HIGH) ; // Apagamos fila antes de salir | |
} | |
} | |
bool GetBit( byte N, int pos) | |
{ // pos = 7 6 5 4 3 2 1 0 | |
int b = N >> pos ; // Shift bits | |
b = b & 1 ; // coger solo el ultimo bit | |
return b ; | |
} | |
void Clear() | |
{ | |
for (int j=2; j<10; j++) // Valores de los pines de columna | |
digitalWrite(j, LOW); // Todos apagados | |
for (int k= 10 ; k<18 ; k++) | |
digitalWrite(k, HIGH); // Todas las filas cortadas | |
} | |
byte Selecciona( char c, byte fil) | |
{ | |
if ( c == 'P') return(P[fil]) ; | |
if ( c == 'R') return( R[fil]) ; | |
if ( c == 'O') return( O[fil]); | |
if (c == 'M') return( M[fil]); | |
if (c == 'E') return( E[fil]); | |
if (c == 'T') return( T[fil]); | |
if (c == 'C') return( C[fil]); | |
if (c == 'N') return( N[fil]); | |
if (c == '.') return( dot[fil]); | |
if (c == ' ') return( sp[fil]); | |
} | |
void loop() | |
{ | |
String s = "PROMETEC.NET " ; | |
int l = s.length(); // Calcula la longitus de s | |
for ( int n = 0; n< l; n++ ) | |
{ | |
long t = millis(); | |
char c = s[n]; | |
while ( millis()< t+ 400) | |
SetChar(c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment