Advertisement
Drakkheen

Untitled

Mar 10th, 2021
1,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const byte zeile[] = {4, 5, 6, 7, 8};
  2. const byte spalte[] = {9, 10, 11, 12, 13};
  3.  
  4. int timeCount = 0;
  5.  
  6. const byte charTable[][30] = {
  7.   {0b01100, 0b10010, 0b11110, 0b10010, 0b10010},          //A
  8.   {0b11100, 0b10010, 0b11110, 0b10010, 0b11100},          //B
  9.   {0b01110, 0b10000, 0b10000, 0b10000, 0b01110},          //C
  10.   {0b11100, 0b10010, 0b10010, 0b10010, 0b11100},          //D
  11.   {0b11110, 0b10000, 0b11100, 0b10000, 0b11110},          //E
  12.   {0b11110, 0b10000, 0b11100, 0b10000, 0b10000},          //F
  13.   {0b01110, 0b10000, 0b10110, 0b10010, 0b11110},          //G
  14.   {0b10010, 0b10010, 0b11110, 0b10010, 0b10010},          //H
  15.   {0b00100, 0b00100, 0b00100, 0b00100, 0b00100},          //I
  16.   {0b00100, 0b00100, 0b00100, 0b10100, 0b11100},          //J
  17.   {0b10010, 0b10100, 0b11000, 0b10100, 0b10010},          //K
  18.   {0b10000, 0b10000, 0b10000, 0b10000, 0b11110},          //L
  19.   {0b10001, 0b11011, 0b10101, 0b10001, 0b10001},          //M
  20.   {0b10010, 0b11010, 0b10110, 0b10010, 0b10010},          //N
  21.   {0b01100, 0b10010, 0b10010, 0b10010, 0b01100},          //O
  22.   {0b11100, 0b10010, 0b10010, 0b11100, 0b10000},          //P
  23.   {0b01110, 0b10001, 0b10101, 0b10010, 0b01101},          //Q
  24.   {0b11100, 0b10010, 0b11100, 0b10010, 0b10010},          //R
  25.   {0b11110, 0b10000, 0b11110, 0b00010, 0b11110},          //S
  26.   {0b11111, 0b00100, 0b00100, 0b00100, 0b00100},          //T
  27.   {0b10010, 0b10010, 0b10010, 0b10010, 0b01100},          //U
  28.   {0b10001, 0b10001, 0b10001, 0b01010, 0b00100},          //V
  29.   {0b10001, 0b10001, 0b10101, 0b10101, 0b01110},          //W
  30.   {0b10010, 0b10010, 0b01100, 0b10010, 0b10010},          //X
  31.   {0b10001, 0b10001, 0b01110, 0b00100, 0b00100},          //Y
  32.   {0b11110, 0b00010, 0b00100, 0b01000, 0b11110},          //Z
  33.   {0b00000, 0b00000, 0b00000, 0b00000, 0b00000},          //EX
  34.   {0b11111, 0b11111, 0b11111, 0b11111, 0b11111},          //ALL
  35.   {0b01010, 0b00000, 0b00100, 0b10001, 0b01110},          //smile
  36.   {0b10001, 0b00100, 0b00000, 0b01110, 0b10001},          //frown
  37. };
  38.  
  39. const byte firstChar = 'A';                            // mit welchem Zeichen beginnt der charTable
  40.  
  41. void setup() {
  42.   Serial.begin(9600);
  43.  
  44.   for (size_t i = 0; i < sizeof(zeile); i++) {
  45.     pinMode(zeile[i], OUTPUT);
  46.   }
  47.   for (size_t i = 0; i < sizeof(spalte); i++) {
  48.     pinMode(spalte[i], OUTPUT);
  49.   }
  50. }
  51.  
  52. void loop() {
  53.   char myStr[] = "OI"; // Variable mit dem anzuzeigenden Text
  54.  
  55.   wort(myStr, sizeof(myStr) - 1);
  56. }
  57.  
  58. void wort(char *toPrint, size_t len)
  59. {
  60.   for (size_t i = 0; i < len; i++)
  61.   {
  62.     // convert character to a variable
  63.     byte myIndex = toPrint[i] - firstChar; // ASCII minus erstem Zeichen somit 0 für das erste Zeichen in deinem Char-Table
  64.  
  65.  
  66.     // Hier beginnt das Drama -----------------------
  67.     // meiner Meinung nch sollte er 1000x durchlaufen und das entsprechende Zeichen anzeigen
  68.     // wenn 1000 erreicht ist geht der Zähler auf 0 und das nächste Zeichen kommt 1000 x
  69.     // Tut er aber so nicht. Es werden beide Zeichen gleichzeitig gezeigt.
  70.  
  71.     if (timeCount <  1000)
  72.     {
  73.       timeCount ++;
  74.  
  75.       zeige(charTable[myIndex]);
  76.       //  Serial.println(timeCount);  // sobald die ersten // entfernt werden bremst das Programm und die LEDs leuchten nur noch schwach.
  77.     }
  78.     else {
  79.       timeCount = 0;
  80.     }
  81.   }
  82. }
  83.  
  84. // ***** Ausgabe an die 5x5 LED MAtrix ******
  85. void zeige(const byte buffer2[]) {
  86.   for (int a = 0; a <= 4; a++) {
  87.     digitalWrite(zeile[a], 1);
  88.     for (int i = 0; i < 5; i++) {
  89.       digitalWrite(spalte[i], bitRead (buffer2[a], i));
  90.       digitalWrite(spalte[i], 0);
  91.     }
  92.     digitalWrite(zeile[a], 0);
  93.   }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement