Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Glediator Arduino UNO sketch by Jens Andrée
- // Some changes and testing by Nils Gregersen, www.hamburgtech.de, [email protected]
- // sdcard bug fixed by Pascal also from Hamburg, [email protected]
- #include <FastLED.h>
- #include <SPI.h>
- #include <SD.h>
- #define NUM_LEDS 364 // LED number
- #define DATA_PIN 2 // your data arduino pin
- #define CHIPSET WS2811 // your LED chip type
- #define CMD_NEW_DATA 1
- //#define BAUD_RATE 500000 //if using Glediator via serial
- unsigned char x = 11; // matrix x size
- unsigned char y = 11; // matrix y size
- File fxdata;
- CRGB leds[NUM_LEDS];
- CRGB tmp[NUM_LEDS];
- const uint16_t XYTable[] = {
- 0, 51, 52, 103, 104, 155, 156, 207, 208, 259, 260, 311, 312, 363, 364, 415,
- 1, 50, 53, 102, 105, 154, 157, 206, 209, 258, 261, 310, 313, 362, 365, 414,
- 2, 49, 54, 101, 106, 153, 158, 205, 210, 257, 262, 309, 314, 361, 366, 413,
- 3, 48, 55, 100, 107, 152, 159, 204, 211, 256, 263, 308, 315, 360, 367, 412,
- 4, 47, 56, 99, 108, 151, 160, 203, 212, 255, 264, 307, 316, 359, 368, 411,
- 5, 46, 57, 98, 109, 150, 161, 202, 213, 254, 265, 306, 317, 358, 369, 410,
- 6, 45, 58, 97, 110, 149, 162, 201, 214, 253, 266, 305, 318, 357, 370, 409,
- 7, 44, 59, 96, 111, 148, 163, 200, 215, 252, 267, 304, 319, 356, 371, 408,
- 8, 43, 60, 95, 112, 147, 164, 199, 216, 251, 268, 303, 320, 355, 372, 407,
- 9, 42, 61, 94, 113, 146, 165, 198, 217, 250, 269, 302, 321, 354, 373, 406,
- 10, 41, 62, 93, 114, 145, 166, 197, 218, 249, 270, 301, 322, 353, 374, 405,
- 11, 40, 63, 92, 115, 144, 167, 196, 219, 248, 271, 300, 323, 352, 375, 404,
- 12, 39, 64, 91, 116, 143, 168, 195, 220, 247, 272, 299, 324, 351, 376, 403,
- 13, 38, 65, 90, 117, 142, 169, 194, 221, 246, 273, 298, 325, 350, 377, 402,
- 14, 37, 66, 89, 118, 141, 170, 193, 222, 245, 274, 297, 326, 349, 378, 401,
- 15, 36, 67, 88, 119, 140, 171, 192, 223, 244, 275, 296, 327, 348, 379, 400,
- 16, 35, 68, 87, 120, 139, 172, 191, 224, 243, 276, 295, 328, 347, 380, 399,
- 17, 34, 69, 86, 121, 138, 173, 190, 225, 242, 277, 294, 329, 346, 381, 398,
- 18, 33, 70, 85, 122, 137, 174, 189, 226, 241, 278, 293, 330, 345, 382, 397,
- 19, 32, 71, 84, 123, 136, 175, 188, 227, 240, 279, 292, 331, 344, 383, 396,
- 20, 31, 72, 83, 124, 135, 176, 187, 228, 239, 280, 291, 332, 343, 384, 395,
- 21, 30, 73, 82, 125, 134, 177, 186, 229, 238, 281, 290, 333, 342, 385, 394,
- 22, 29, 74, 81, 126, 133, 178, 185, 230, 237, 282, 289, 334, 341, 386, 393,
- 23, 28, 75, 80, 127, 132, 179, 184, 231, 236, 283, 288, 335, 340, 387, 392,
- 24, 27, 76, 79, 128, 131, 180, 183, 232, 235, 284, 287, 336, 339, 388, 391,
- 25, 26, 77, 78, 129, 130, 181, 182, 233, 234, 285, 286, 337, 338, 389, 390
- };
- void setup()
- {
- FastLED.addLeds<CHIPSET, DATA_PIN, GRB>(leds, NUM_LEDS); //see doc for different LED strips
- FastLED.setBrightness(30);
- // Serial.begin(BAUD_RATE); // when using Glediator via usb
- Serial.begin(115200);
- for (int y = 0 ; y < NUM_LEDS ; y++)
- {
- leds[y] = CRGB::Black; // set all leds to black during setup
- }
- FastLED.show();
- pinMode(10, OUTPUT); // CS/SS pin as output for SD library to work.
- digitalWrite(10, HIGH); // workaround for sdcard failed error...
- if (!SD.begin(BUILTIN_SDCARD))
- {
- Serial.println("sdcard initialization failed!");
- return;
- }
- Serial.println("sdcard initialization done.");
- // test file open
- fxdata = SD.open("dwain1.out"); // read only
- if (fxdata)
- {
- Serial.println("file open ok");
- fxdata.close();
- }
- }
- int serialGlediator ()
- {
- while (!Serial.available()) {}
- return Serial.read();
- }
- void loop()
- {
- fxdata = SD.open("dwain.dat"); // read only
- if (fxdata)
- {
- Serial.println("file open ok");
- }
- while (fxdata.available())
- {
- for (int i=0; i < NUM_LEDS; i++) {
- tmp[i].r = 0;//fxdata.read();
- tmp[i].g = 0;//fxdata.read();
- tmp[i].b = 0;//fxdata.read();
- }
- //fxdata.readBytes((char*)tmp, NUM_LEDS * 3);
- tmp[1].r=255;
- //tmp[2].b=255;
- for (int i=0; i < NUM_LEDS; i++) {
- //leds[i] = tmp[i];
- leds[i] = tmp[XYTable[i]];
- Serial.print(i);
- Serial.print(" = ");
- Serial.print(XYTable[i]);
- Serial.print(" = ");
- Serial.print(tmp[i]);
- //Serial.print(tmp[XYTable[i]].g);
- //Serial.print(tmp[XYTable[i]].b);
- Serial.println();
- }
- FastLED.show();
- }
- fxdata.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment