Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ** Laboratorio #10: Mostrar un mensaje desplazándose de izquierda a
- * derecha en una matriz LED 8x8 a travésde IC MAX7219
- * enviado desde un Arduino, pueden usar una interfaz Processing.
- * Autor: Sebastian Palacios Tovar
- */
- */
- //incluimos libreria LedControl
- #include "LedControl.h"
- String texto="Ingrese Texto:";
- LedControl lc=LedControl(12,11,10,1);
- /* we always wait a bit between updates of the display */
- unsigned long delaytime=30
- ;
- void setup() {
- Serial.begin(9600);
- lc.shutdown(0,false);
- /* Set the brightness to a medium values */
- lc.setIntensity(0,8);
- /* and clear the display */
- lc.clearDisplay(0);
- }
- char abcMAY[36]={'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','1','2', '3', '4', '5', '6', '7', '8', '9', '0'};
- char abcMIN[36]={'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','1','2', '3', '4', '5', '6', '7', '8', '9', '0'};
- byte letras[36][5]= { {B11111110,B00010001,B00010001,B00010001,B11111110},//A
- {0xFF, 0x89, 0x89, 0x89, 0x76},//B
- {B01111110,B10000001,B10000001,B10000001,B01000110},//C
- {0xff, 0x81, 0x81, 0x81, 0x7e},//D
- {0x7e, 0x89, 0x89, 0x89, 0x89},//E
- {0xff, 0x09, 0x09, 0x09, 0x01},//F
- {0x7e, 0x89, 0x89, 0x89, 0xf2},//G
- {0xFF, 0x18, 0x18, 0x18,0xff},//H
- {B00000000,B10000100,B11111101,B10000000,B00000000},//I
- {0x71, 0x81, 0x7f, 0x01, 0x01},//J
- {0xff, 0x10, 0x2c, 0x42, 0x81},//K
- {0x7f, 0xc0, 0x80,0x80, 0x80},//L
- {0xff, 0x06, 0x0c, 0x06, 0xff},//M
- {B11111111,B00000100,B00001000,B00010000,B11111111}, //N
- {B01111110,B10000001,B10000001,B10000001,B01111110},//O
- {0xff, 0x09, 0x09, 0x09, 0x06},//P
- {0xbe, 0x41,0xA1, 0x81, 0x7e},//Q
- {B11111111,B00010001,B00110001,B01010001,B10001110},//R
- {0x86, 0x89, 0x89, 0x89, 0x71},//S
- {0x01, 0x01, 0xff, 0x01, 0x01},//T
- {B01111111,B11000000,B11000000,B11000000,B01111111},//U
- {0x3f, 0x40, 0x80, 0x40, 0x3f},//V
- {0x7f, 0x80, 0x70, 0x80, 0x7f},//W
- {0xe3, 0x14, 0x08, 0x14, 0xe3},//X
- {0x03, 0x04, 0xf8, 0x04, 0x03},//Y
- {0xe1, 0x91, 0x89, 0x85, 0x83 }//Z
- ,{0x00, 0x82, 0xff, 0x80,0x00},//1
- {0xc2, 0xa1, 0x91, 0x89, 0x86},//2
- {0x81,0x81,0x85,0x8b,0x71},//3
- {0x18,0x14, 0x12, 0xff, 0x00},//4
- {0x8f, 0x89, 0x89, 0x89, 0x71},//5
- {0x7c, 0x8a, 0x89, 0x89, 0x70},//6
- {0x01, 0xf1, 0x09,0x05, 0x03},//7
- {0x76, 0x89, 0x89, 0x89, 0x76},//8
- {0x06, 0x89, 0x89, 0x89, 0x7e },//9
- {B01111110,B11100001,B10011001,B10000111,B01111110},//O
- };
- void writeArduinoOnMatrix(String mensajea) {
- /* here is the data for the characters */
- for(int j=0;j<mensajea.length();j++){
- for(int k=0;k<36;k++){
- if(mensajea.charAt(j)==abcMAY[k] || mensajea.charAt(j)==abcMIN[k]){
- palabras(letras[k]);
- }
- }
- }
- }
- void palabras(byte listd[]){
- for(int j=7;j>-4;j--){
- for(int i=4; i> -1; i--){
- lc.setRow(0,j+i,listd[i]);
- }
- delay(delaytime);
- for(int o=0; o<8 ; o++){
- lc.setRow(0,o,0);
- }
- }
- }
- void loop() {
- writeArduinoOnMatrix(texto);
- }
- void serialEvent(){
- while(Serial.available()){
- texto= Serial.readString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement