Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ** Laboratorio #10: Mostrar un mensaje desplazándose de izquierda a
  2.  * derecha en una matriz LED 8x8 a travĂ©sde IC MAX7219
  3.  * enviado desde un Arduino, pueden usar una interfaz Processing.
  4.  * Autor: Sebastian Palacios Tovar
  5.  */
  6.  
  7. */
  8. //incluimos libreria LedControl
  9. #include "LedControl.h"
  10. String texto="Ingrese Texto:";
  11.  
  12.  
  13. LedControl lc=LedControl(12,11,10,1);
  14.  
  15. /* we always wait a bit between updates of the display */
  16. unsigned long delaytime=30
  17. ;
  18.  
  19. void setup() {
  20.   Serial.begin(9600);
  21.  
  22.   lc.shutdown(0,false);
  23.   /* Set the brightness to a medium values */
  24.   lc.setIntensity(0,8);
  25.   /* and clear the display */
  26.   lc.clearDisplay(0);
  27. }
  28. 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'};
  29. 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'};
  30. byte letras[36][5]= { {B11111110,B00010001,B00010001,B00010001,B11111110},//A
  31.   {0xFF, 0x89, 0x89, 0x89, 0x76},//B
  32.   {B01111110,B10000001,B10000001,B10000001,B01000110},//C
  33.   {0xff, 0x81, 0x81, 0x81, 0x7e},//D
  34.   {0x7e, 0x89, 0x89, 0x89, 0x89},//E
  35.   {0xff, 0x09, 0x09, 0x09, 0x01},//F
  36.   {0x7e, 0x89, 0x89, 0x89, 0xf2},//G
  37.   {0xFF, 0x18, 0x18, 0x18,0xff},//H
  38.   {B00000000,B10000100,B11111101,B10000000,B00000000},//I
  39.   {0x71, 0x81, 0x7f, 0x01, 0x01},//J
  40.   {0xff, 0x10, 0x2c, 0x42, 0x81},//K
  41.   {0x7f, 0xc0, 0x80,0x80, 0x80},//L
  42.   {0xff, 0x06, 0x0c, 0x06, 0xff},//M
  43.   {B11111111,B00000100,B00001000,B00010000,B11111111}, //N
  44.   {B01111110,B10000001,B10000001,B10000001,B01111110},//O
  45.   {0xff, 0x09, 0x09, 0x09, 0x06},//P
  46.   {0xbe, 0x41,0xA1, 0x81, 0x7e},//Q
  47.   {B11111111,B00010001,B00110001,B01010001,B10001110},//R
  48.   {0x86, 0x89, 0x89, 0x89, 0x71},//S
  49.   {0x01, 0x01, 0xff, 0x01, 0x01},//T
  50.   {B01111111,B11000000,B11000000,B11000000,B01111111},//U
  51.   {0x3f, 0x40, 0x80, 0x40, 0x3f},//V
  52.   {0x7f, 0x80, 0x70, 0x80, 0x7f},//W
  53.   {0xe3, 0x14, 0x08, 0x14, 0xe3},//X
  54.   {0x03, 0x04, 0xf8, 0x04, 0x03},//Y
  55.   {0xe1, 0x91, 0x89, 0x85, 0x83 }//Z
  56.  
  57.   ,{0x00, 0x82, 0xff, 0x80,0x00},//1
  58.   {0xc2, 0xa1, 0x91, 0x89, 0x86},//2
  59.   {0x81,0x81,0x85,0x8b,0x71},//3
  60.   {0x18,0x14, 0x12, 0xff, 0x00},//4
  61.   {0x8f, 0x89, 0x89, 0x89, 0x71},//5
  62.   {0x7c, 0x8a, 0x89, 0x89, 0x70},//6
  63.   {0x01, 0xf1, 0x09,0x05, 0x03},//7
  64.   {0x76, 0x89, 0x89, 0x89, 0x76},//8
  65.   {0x06, 0x89, 0x89, 0x89, 0x7e },//9
  66.   {B01111110,B11100001,B10011001,B10000111,B01111110},//O
  67. };
  68.  
  69. void writeArduinoOnMatrix(String mensajea) {
  70.  
  71.   /* here is the data for the characters */
  72.  
  73.  
  74.  for(int j=0;j<mensajea.length();j++){
  75.    for(int k=0;k<36;k++){
  76.  if(mensajea.charAt(j)==abcMAY[k] || mensajea.charAt(j)==abcMIN[k]){
  77.  palabras(letras[k]);
  78.  }
  79.  }
  80.  }
  81.  
  82. }
  83. void palabras(byte listd[]){
  84.   for(int j=7;j>-4;j--){
  85.    
  86.   for(int i=4; i> -1; i--){
  87.   lc.setRow(0,j+i,listd[i]);
  88.   }
  89.   delay(delaytime);
  90.   for(int o=0; o<8 ; o++){
  91.   lc.setRow(0,o,0);
  92.   }
  93.   }
  94. }
  95.  
  96. void loop() {
  97.   writeArduinoOnMatrix(texto);
  98.  
  99. }
  100.  
  101. void serialEvent(){
  102. while(Serial.available()){
  103. texto= Serial.readString();
  104. }