Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //libreria
  2. #include "LedControl.h"
  3.  
  4. //pin 12  DataIn:din
  5. //pin 11   CLK
  6. //pin 10   LOAD : cs
  7.  
  8. LedControl lc = LedControl(12,11,10,1);
  9.  
  10. //ASCII TABLE
  11.  
  12.  byte chars[129][8] = {
  13.     {0,0,0,0,0,0,0,0}, // 0
  14.   {0,0,0,0,0,0,0,0}, // 1
  15.   {0,0,0,0,0,0,0,0}, // 2
  16.   {0,0,0,0,0,0,0,0}, // 3
  17.   {0,0,0,0,0,0,0,0}, // 4
  18.   {0,0,0,0,0,0,0,0}, // 5
  19.   {0,0,0,0,0,0,0,0}, // 6
  20.   {0,0,0,0,0,0,0,0}, // 7
  21.   {0,0,0,0,0,0,0,0}, // 8
  22.   {0,0,0,0,0,0,0,0}, // 9
  23.   {0,0,0,0,0,0,0,0}, // 10
  24.   {0,0,0,0,0,0,0,0}, // 11
  25.   {0,0,0,0,0,0,0,0}, // 12
  26.   {0,0,0,0,0,0,0,0}, // 13
  27.   {0,0,0,0,0,0,0,0}, // 14
  28.   {0,0,0,0,0,0,0,0}, // 15
  29.   {0,0,0,0,0,0,0,0}, // 16
  30.   {0,0,0,0,0,0,0,0}, // 17
  31.   {0,0,0,0,0,0,0,0}, // 18
  32.   {0,0,0,0,0,0,0,0}, // 19
  33.   {0,0,0,0,0,0,0,0}, // 20
  34.   {0,0,0,0,0,0,0,0}, // 21
  35.   {0,0,0,0,0,0,0,0}, // 22
  36.   {0,0,0,0,0,0,0,0}, // 23
  37.   {0,0,0,0,0,0,0,0}, // 24
  38.   {0,0,0,0,0,0,0,0}, // 25
  39.   {0,0,0,0,0,0,0,0}, // 26
  40.   {0,0,0,0,0,0,0,0}, // 27
  41.   {0,0,0,0,0,0,0,0}, // 28
  42.   {0,0,0,0,0,0,0,0}, // 29
  43.   {0,0,0,0,0,0,0,0}, // 30
  44.   {0,0,0,0,0,0,0,0}, // 31
  45.   {0,0,0,0,0,0,0,0}, // 32
  46.   {0,0,0,0,0,0,0,0}, // 33
  47.   {0,0,0,0,0,0,0,0}, // 34
  48.   {0,0,0,0,0,0,0,0}, // 35
  49.   {0,0,0,0,0,0,0,0}, // 36
  50.   {0,0,0,0,0,0,0,0}, // 37
  51.   {0,0,0,0,0,0,0,0}, // 38
  52.   {0,0,0,0,0,0,0,0}, // 39
  53.   {0,0,0,0,0,0,0,0}, // 40
  54.   {0,0,0,0,0,0,0,0}, // 41
  55.   {0,0,0,0,0,0,0,0}, // 42
  56.   {0,0,0,0,0,0,0,0}, // 43
  57.   {0,0,0,0,0,0,0,0}, // 44
  58.   {0,0,0,0,0,0,0,0}, // 45
  59.   {0,0,0,0,0,0,0,0}, // 46
  60.   {0,0,0,0,0,0,0,0}, // 47
  61.   {0,0,0,0,0,0,0,0}, // 48
  62.   {0,0,0,0,0,0,0,0}, // 49
  63.   {0,0,0,0,0,0,0,0}, // 50
  64.   {0,0,0,0,0,0,0,0}, // 51
  65.   {0,0,0,0,0,0,0,0}, // 52
  66.   {0,0,0,0,0,0,0,0}, // 53
  67.   {0,0,0,0,0,0,0,0}, // 54
  68.   {0,0,0,0,0,0,0,0}, // 55
  69.   {0,0,0,0,0,0,0,0}, // 56
  70.   {0,0,0,0,0,0,0,0}, // 57
  71.   {0,0,0,0,0,0,0,0}, // 58
  72.   {0,0,0,0,0,0,0,0}, // 59
  73.   {0,0,0,0,0,0,0,0}, // 60
  74.   {0,0,0,0,0,0,0,0}, // 61
  75.   {0,0,0,0,0,0,0,0}, // 62
  76.   {0,0,0,0,0,0,0,0}, // 63
  77.   {0,0,0,0,0,0,0,0}, // 64
  78.   {B11110110,B11111111,B00001001,B00001001,B00001001,B00001001,B11111111,B11110110}, // 65A
  79.   {B11111111,B11111111,B10001001,B10001001,B10001001,B10001001,B11111111,B01110110}, // 66B
  80.   {B11111111,B11111111,B11100111,B11000011,B11000011,B11000011,B11000011,B11000011}, // 67C
  81.   {B11111111,B11111111,B11000011,B11000011,B11000011,B11000011,B11111111,B01111110}, // 68D
  82.   {B01111110,B11111111,B11011011,B11011011,B11011011,B11000011,B11000011,B00000000},//E
  83.   {B11111110,B11111111,B00110011,B00110011,B00110011,B00110011,B00110011,B00000000},//F
  84.   {B11111110,B11111111,B10000011,B10011011,B10011011,B10011011,B10011011,B11110011},//G
  85.   {B11111111,B11111111,B00011000,B00011000,B00011000,B00011000,B11111111,B11111111},//H
  86.   {B11000011,B11000011,B11000011,B11111111,B11111111,B11000011,B11000011,B11000011},//I
  87.   {B11000011,B11000011,B11000011,B11111111,B11111111,B00000011,B00000011,B00000011},//J
  88.   {B11111111,B11111111,B00011000,B00011000,B00111100,B01100110,B11000011,B10000001},//K
  89.   {B11111111,B11111111,B11100000,B11000000,B11000000,B11000000,B11000000,B00000000},//L
  90.   {B11111111,B11111111,B00000110,B00011100,B00011100,B00000110,B11111111,B11111111},//M
  91.   {B11111111,B11111111,B00000110,B00001100,B00011000,B00110000,B11111111,B11111111},//N
  92.   {B01111110,B11111111,B11000011,B10000001,B10000001,B11000011,B11111111,B01111110},//O
  93.   {B11111110,B11111111,B00011111,B00010001,B00010001,B00011111,B00011111,B00000000},//P
  94.   {B00111110,B01111111,B01000001,B01000001,B01010001,B01100001,B01111111,B10111110},//Q
  95.   {B11111110,B11111111,B00011001,B00011001,B00011001,B00111001,B11011111,B10001110},//R
  96.   {B11001110,B11011111,B11011011,B11011011,B11011011,B11011011,B11111011,B01110011}, // 83S
  97.   {B00000011,B00000011,B00000011,B11111111,B11111111,B00000011,B00000011,B00000011}, // 84T
  98.   {B11111111,B11111111,B11000000,B11000000,B11000000,B11000000,B11111111,B11111111}, // 85U
  99.   {B00011111,B00111100,B01110000,B11100000,B11100000,B01110000,B00111100,B00011111},//V
  100.   {B00111110,B01111000,B11110000,B00111000,B00111000,B11110000,B01111000,B00111110},//W
  101.   {B10000001,B11000011,B01100110,B00011000,B00011000,B01100110,B11000011,B10000001},//X
  102.   {B00000001,B00000111,B00001100,B11111000,B11111000,B00001100,B00000111,B00000001},//Y
  103.   {B11000001,B11100001,B11110001,B10111001,B10011101,B10001111,B10000111,B10000011},//Z
  104.   {0,0,0,0,0,0,0,0}, // 91
  105.   {0,0,0,0,0,0,0,0}, // 92
  106.   {0,0,0,0,0,0,0,0}, // 93
  107.   {0,0,0,0,0,0,0,0}, // 94
  108.   {0,0,0,0,0,0,0,0}, // 95
  109.   {0,0,0,0,0,0,0,0}, // 96
  110.   {B11110110,B11111111,B00001001,B00001001,B00001001,B00001001,B11111111,B11110110}, // 65A
  111.   {B11111111,B11111111,B10001001,B10001001,B10001001,B10001001,B11111111,B01110110}, // 66B
  112.   {B11111111,B11111111,B11100111,B11000011,B11000011,B11000011,B11000011,B11000011}, // 67C
  113.   {B11111111,B11111111,B11000011,B11000011,B11000011,B11000011,B11111111,B01111110}, // 68D
  114.   {B01111110,B11111111,B11011011,B11011011,B11011011,B11000011,B11000011,B00000000},//E
  115.   {B11111110,B11111111,B00110011,B00110011,B00110011,B00110011,B00110011,B00000000},//F
  116.   {B11111110,B11111111,B10000011,B10011011,B10011011,B10011011,B10011011,B11110011},//G
  117.   {B11111111,B11111111,B00011000,B00011000,B00011000,B00011000,B11111111,B11111111},//H
  118.   {B11000011,B11000011,B11000011,B11111111,B11111111,B11000011,B11000011,B11000011},//I
  119.   {B11000011,B11000011,B11000011,B11111111,B11111111,B00000011,B00000011,B00000011},//J
  120.   {B11111111,B11111111,B00011000,B00011000,B00111100,B01100110,B11000011,B10000001},//K
  121.   {B11111111,B11111111,B11100000,B11000000,B11000000,B11000000,B11000000,B00000000},//L
  122.   {B11111111,B11111111,B00000110,B00011100,B00011100,B00000110,B11111111,B11111111},//M
  123.   {B11111111,B11111111,B00000110,B00001100,B00011000,B00110000,B11111111,B11111111},//N
  124.   {B01111110,B11111111,B11000011,B10000001,B10000001,B11000011,B11111111,B01111110},//O
  125.   {B11111110,B11111111,B00011111,B00010001,B00010001,B00011111,B00011111,B00000000},//P
  126.   {B00111110,B01111111,B01000001,B01000001,B01010001,B01100001,B01111111,B10111110},//Q
  127.   {B11111110,B11111111,B00011001,B00011001,B00011001,B00111001,B11011111,B10001110},//R
  128.   {B11001110,B11011111,B11011011,B11011011,B11011011,B11011011,B11111011,B01110011}, // 83S
  129.   {B00000011,B00000011,B00000011,B11111111,B11111111,B00000011,B00000011,B00000011}, // 84T
  130.   {B11111111,B11111111,B11000000,B11000000,B11000000,B11000000,B11111111,B11111111}, // 85U
  131.   {B00011111,B00111100,B01110000,B11100000,B11100000,B01110000,B00111100,B00011111},//V
  132.   {B00111110,B01111000,B11110000,B00111000,B00111000,B11110000,B01111000,B00111110},//W
  133.   {B10000001,B11000011,B01100110,B00011000,B00011000,B01100110,B11000011,B10000001},//X
  134.   {B00000001,B00000111,B00001100,B11111000,B11111000,B00001100,B00000111,B00000001},//Y
  135.   {B11000001,B11100001,B11110001,B10111001,B10011101,B10001111,B10000111,B10000011},//Z
  136.   {0,0,0,0,0,0,0,0}, // 123
  137.   {0,0,0,0,0,0,0,0}, // 124
  138.   {0,0,0,0,0,0,0,0}, // 125
  139.   {0,0,0,0,0,0,0,0}, // 126
  140.   {0,0,0,0,0,0,0,0}, // 127
  141.   {0,0,0,0,0,0,0,0} // 128
  142. };
  143.  
  144.  
  145.  
  146. void setup() {
  147.    
  148.   lc.shutdown(0,false);
  149.   /* Set the brightness to a medium values */
  150.   lc.setIntensity(0,8);
  151.   /* and clear the display */
  152.   lc.clearDisplay(0);
  153.  
  154.   Serial.begin(9600);
  155.  
  156. }
  157.  
  158. /*
  159.  This method will display the characters for the
  160.  word "Arduino" one after the other on the matrix.
  161.  (you need at least 5x7 leds to see the whole chars)
  162.  */
  163. void writeChar(char chLetter, int nuDelayTime) {
  164.    
  165.       for (int i=0; i<8; i++){
  166.           lc.setRow(0,i,chars[chLetter][i]);
  167.       }
  168.        
  169.     delay(nuDelayTime);
  170.  
  171. }
  172.  
  173. void loop() {
  174.  
  175.   Serial.flush();
  176.  
  177.   if (Serial.available() > 0) {
  178.  
  179.     char chLetter = Serial.read();
  180.    
  181.     writeChar(chLetter,700);
  182.    
  183.   }  
  184.  
  185. }