Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Matrix Serial Read

  1. #11
    Join Date
    Dec 2011
    Posts
    7,302
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Quote Originally Posted by skykicker View Post
    Thanks I will give that a shot when I get a chance.
    Your best friend in designing your Fastled matrix/array is the Fastled wiki combined with the fastled -Arduino code examples .

  2. #12
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Thumbs up original multi pin code

    Here is the original code I am trying to modify

    Code:
    // header in vixen must be >>###<<  ### will be your total number of leds
    
    
    // You must download and install the library from http://fastled.io/ 
    #include <FastLED.h>
    
    #define NUM_STRIPS 4                             // Changed from original for 3 strings
    #define NUM_LEDS_PER_STRIP 63                    // Using 63 pixels per string
    #define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS // Total number of LEDs
    
    CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
    
    
    void setup() {
        // Define the speed of the serial port
    Serial.begin(115200);
    }
    
    void loop() {
        // Set some counter / temporary storage variables
    int cnt;
    unsigned int num_leds;
    unsigned int d1, d2, d3;
    
        // Begin an endless loop to receive and process serial data
    for(;;) {
        // Set a counter to 0. This couter keeps track of the pixel colors received.
    cnt = 0;
        //Begin waiting for the header to be received on the serial bus
        //1st character
    while(!Serial.available());
    if(Serial.read() != '>') {
    continue;
    }
        //second character
    while(!Serial.available());
    if(Serial.read() != '>') {
    continue;
    }
        //get the first digit from the serial bus for the number of pixels to be used
    while(!Serial.available());
    d1 = Serial.read();
        //get the second digit from the serial bus for the number of pixels to be used
    while(!Serial.available());
    d2 = Serial.read();
        //get the third digit from the serial bus for the number of pixels to be used
    while(!Serial.available());
    d3 = Serial.read();
        //get the end of the header
    while(!Serial.available());
    if(Serial.read() != '<') {
    continue;
    }
    while(!Serial.available());
    if(Serial.read() != '<') {
    continue;
    }
        // calculate the number of pixels based on the characters provided in the header digits
    num_leds = (d1-'0')*100+(d2-'0')*10+(d3-'0');
        // ensure the number of pixels does not exceed the number allowed
    if(num_leds > NUM_LEDS) {
    continue;
    }
    
        // CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 8, starting at index 0 in the led array
        //this line change for one long string
     FastLED.addLeds<WS2811, 8,RGB>(leds, 0, NUM_LEDS_PER_STRIP);
        // CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 9, starting at index 64 in the led array
     FastLED.addLeds<WS2811, 9,RGB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
        // CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 10, starting at index 127 in the led array
     FastLED.addLeds<WS2811, 10,RGB>(leds, NUM_LEDS_PER_STRIP*2, NUM_LEDS_PER_STRIP);
        // CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 11, starting at index 190 in the led array
     FastLED.addLeds<WS2811, 11,RGB>(leds, NUM_LEDS_PER_STRIP*3, NUM_LEDS_PER_STRIP);
        // FastLED.addLeds<WS2811, 8,RGB>(leds, 0, 256);
    
    do {
    while(!Serial.available());
    leds[cnt].r = Serial.read();
    while(!Serial.available());
    leds[cnt].g = Serial.read();
    while(!Serial.available());
    leds[cnt++].b = Serial.read();
    } 
    while(--num_leds);    // Tell the FastLED Library it is time to update the strip of pixels
    FastLED.show();       // WOO HOO... We are all done and are ready to start over again!
    }
    }
    this works great if all strings are the same size.

  3. #13
    Join Date
    Dec 2011
    Posts
    7,302
    Post Thanks / Like

    Default Re: Matrix Serial Read

    If this works great ,I would suggest building your prop to suit what the firmware will support .
    It is much easier to configure the simple pixel wiring layout then it is write or re-write complex code .

  4. #14
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Found out when I put header to >>999<< some of the second matrix work, any more and neither work guess just have to have only the 44x22 matrix. Unless there is something else I am missing.

  5. #15
    Join Date
    Oct 2014
    Location
    Sauk City, WI USA
    Posts
    1,969
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Quote Originally Posted by skykicker View Post
    Found out when I put header to >>999<< some of the second matrix work, any more and neither work guess just have to have only the 44x22 matrix. Unless there is something else I am missing.
    If you went over 3 digits, did you change the vixen start code in the sketch to read 4 digits? d1, d2, d3 would also need d4

    while(!Serial.available());
    d1 = Serial.read();
    //get the second digit from the serial bus for the number of pixels to be used
    while(!Serial.available());
    d2 = Serial.read();
    //get the third digit from the serial bus for the number of pixels to be used
    while(!Serial.available());
    d3 = Serial.read();

    and here you would do *1000 for d1, etc
    num_leds = (d1-'0')*100+(d2-'0')*10+(d3-'0');

  6. #16
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Wow I can't believe I didn't think of that. Its been years since I was programming. That's why I love these forums. If you forget something there most likely be someone to help. Thanks so much. After you mentioned it I was like "DUH". That makes so much sense the other code only looked for three didgets.


    Sent from my SM-F926U using Tapatalk

  7. #17
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Great news both grids work great.

    Sent from my SM-F926U using Tapatalk

  8. #18
    Join Date
    Dec 2011
    Posts
    7,302
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Quote Originally Posted by skykicker View Post
    Great news both grids work great.

    Sent from my SM-F926U using Tapatalk
    This is excellent . What was the code resolution ? Could this be done without A sequencer ?

  9. #19
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Default Re: Matrix Serial Read


  10. #20
    Join Date
    Mar 2015
    Location
    Kent, WA
    Posts
    29
    Post Thanks / Like

    Default Re: Matrix Serial Read

    Will post the final soon. When I get back to the computer. I do have one with the matrix that will keep repeating what ever line you like with put sequencer. Both will be posted tomorrow.

    Sent from my SM-F926U using Tapatalk

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •