Advertisement
Guest User

FastLED Letters

a guest
Jul 28th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.08 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. #define NUM_LEDS 63
  4. #define DATA_PIN 2
  5. #define CLOCK_PIN 3
  6.  
  7. // Define the array of leds
  8. CRGB leds[NUM_LEDS];
  9.  
  10. int leds_left[] = {42,44,43,47,46,45,51,50,49,48,56,55,54,53,52,62,61,60,59,58,57}; //led_side[0]
  11. int leds_right[] = {41,39,40,36,37,38,32,33,34,35,27,28,29,30,31,21,22,23,24,25,26};  //led_side[1]
  12. int leds_back[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};  //led_side[2]
  13.  
  14. int led_side[][21] = {{42,44,43,47,46,45,51,50,49,48,56,55,54,53,52,62,61,60,59,58,57}, //left
  15.                       {41,39,40,36,37,38,32,33,34,35,27,28,29,30,31,21,22,23,24,25,26}, //right
  16.                       {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}};          //back
  17.  
  18. int ledLetters[][21] = {
  19.   {1,2,5,3,6,7,8,9,14,10}, // 0 = A
  20.   {1,2,5,3,6,7,8,13,11,17,18}, // 1 = B
  21.   {1,2,5,3,6,13,11,17,18}, // 2 = C
  22.   {1,2,5,3,7,9,13,11,17,18}, // 3 = D
  23.   {1,2,5,6,7,8,13,17,18}, // 4 = E
  24.   {1,2,5,6,7,8,13,17}, // 5 = F
  25.   {1,2,5,6,8,9,13,11,17,18}, // 6 = G
  26.   {1,5,3,6,7,8,9,13,11,18}, // 7 = H
  27.   {1,2,4,7,8,12,17,18}, // 8 = I
  28.   {2,3,9,13,11,17,18}, // 9 = J
  29.   {1,5,3,7,8,13,11,17,19}, // 10 = K
  30.   {1,5,7,13,17,18,19}, // 11 = L
  31.   {5,3,6,7,8,9,14,12,10,15,20}, // 12 = M
  32.   {5,6,7,9,14,12,11,15,18}, // 13 = N
  33.   {1,2,5,3,6,9,13,11,17,18}, // 14 = O
  34.   {1,2,5,3,7,8,13,16}, // 15 = P
  35.   {1,2,5,3,6,9,13,11,17,18,19}, // 16 = Q
  36.   {1,2,5,3,6,7,8,14,11,15,19}, // 17 = R
  37.   {2,1,5,7,8,11,18,17}, // 18 = S
  38.   {5,4,3,7,12,17}, // 19 = T
  39.   {5,3,6,9,13,11,17,18}, // 20 = U
  40.   {5,7,9,12,11,18}, // 21 = V
  41.   {5,3,6,9,13,12,11,17,18}, // 22 = W
  42.   {5,3,7,8,12,11,17,19}, // 23 = X
  43.   {5,3,7,8,12,17}, // 24 = Y
  44.   {5,4,3,8,12,17,18,19}, // 25 = Z
  45.   {}, // 26 = LEERZEICHEN
  46.   {1,2,5,3,6,9,13,11,17,18}, // 27 = 0
  47.   {1,2,4,7,8,12,17,18}, // 28 = 1
  48.   {1,2,5,3,8,12,17,18,19}, // 29 = 2
  49.   {1,2,3,7,8,11,17,18}, // 30 = 3
  50.   {0,1,5,6,7,8,9,12,17}, // 31 = 4
  51.   {1,2,5,6,7,8,11,17,18}, // 32 = 5
  52.   {1,2,5,6,7,8,13,11,17,18}, // 33 = 6
  53.   {5,4,3,8,12,17}, // 34 = 7
  54.   {1,2,5,3,7,8,13,11,17,18}, // 35 = 8
  55.   {1,2,5,3,6,7,8,9,11,17,18}, // 36 = 9
  56. };
  57.  
  58. // Hilfsarray fuer die Darstellung von Buchstaben und Ziffern
  59. int letterLength[] = {
  60.   10, // A
  61.   11, // B
  62.   9, // C
  63.   10, // D
  64.   9, // E
  65.   8, // F
  66.   10, // G
  67.   10, // H
  68.   8, // I
  69.   7, // J
  70.   9, // K
  71.   7, // L
  72.   11, // M
  73.   9, // N
  74.   10, // O
  75.   8, // P
  76.   11, // Q
  77.   11, // R
  78.   8, // S
  79.   6, // T
  80.   8, // U
  81.   6, // V
  82.   9, // W
  83.   8, // X
  84.   6, // Y
  85.   8, // Z
  86.   0, // LEERZEICHEN
  87.   10, // 0
  88.   8, // 1
  89.   9, // 2
  90.   8, // 3
  91.   10, // 4
  92.   9, // 5
  93.   10, // 6
  94.   6, // 7
  95.   10, // 8
  96.   11, // 9
  97. };
  98.  
  99. void setup() {
  100.   delay(1000);
  101.   FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  102. }
  103.  
  104. void loop() {
  105.   int hue = random8();
  106.   for(int symbol=0;symbol<37;symbol++){ //gehe alle Symbole durch
  107.     for(int i = 0;i<NUM_LEDS;i++) leds[i] = CRGB::Black;
  108.     for(int side = 0;side<3;side++){      //jede Seite
  109.       for(int j = 0;j<letterLength[symbol];j++){
  110.           leds[led_side[side][ledLetters[symbol][j]]] = CHSV(hue, 255, 255);
  111.         }
  112.       }
  113.   FastLED.show();
  114.   delay(2000);
  115.   }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement