Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Using Vixen to trigger effects in Arduino code

  1. #11
    Join Date
    Dec 2012
    Location
    Newtown CT
    Posts
    4,132
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    What protocol are you using to move the data from the show player to the Arduino? That determines where you will find your data. The data itself is a value between 0 (off) and 255 (full on). The value is based on the intensity you set for your effect. A pulse effect with an intensity of 1 would be what you would use in the sequencer to get the value I mentioned earlier in this thread. Once triggered, I assume your effect would run to completion. If you want to control duration then watch the value until it becomes "not one" and then terminate your effect.


    2020 Full sized show reworked for the new location. Only adding (famous last words) 13 RBLs that I finally got converted to using pixels
    2019 - Just moved into a new home (yet another change of plans). Will be dim but not dark. Too much to do at the new place to leave time for a show. Dim show (3000 pixels) had regular visits most nights.
    https://www.youtube.com/channel/UCyX...ttrsZNARkUce0Q

  2. #12
    Join Date
    Jan 2020
    Posts
    9
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    Hi Martin,

    I'm not a programmer so I don't want to waste your time on this. I am bumping around trying to make it work.

    I'm using a test strip of 53 LED's (WS2812B) sitting at my desk to make things easier to test.
    Arduino Uno
    Vixen 3

    In Vixen I set up a Single Item element and called it "Effect-Data-Channel".
    The Color Handling is set to Single Color with white as the color.

    I also added another Single Item element for the 53 LED strip and called it "Pixel Strip"
    The Color Handling is set to They can be any color - full RGB.

    The controller is a Generic Serial.
    It is set to have 160 channels. (1st for the Effect-Data-Channel and 53x3 for the Pixel Strip)

    The port is set up as Com3, 115200, no parity, 8 data, 1 stop
    The header is >>054<<

    In Vixen I added a "Set Level" effect to the Effect-Data-Channel element and moved the intensity around between 0 and 100.


    For the Arduino sketch I was modifying one I found which works fine for the pixel strip.
    In the code I added an effect called juggle() that I'm trying to call by comparing a variable I added called Effect_Change to the data from the serial read called effect_change.


    Code:
    // You must download and install the library from http://fastled.io/ 
    
    #include <FastLED.h>
    
    
    // Sets the maximum number of LEDs that this code will handle to avoid running out of memory
    
    #define NUM_LEDS 54
    
    
    // Sets the pin which is used to connect to the LED pixel strip
    
    #define DATA_PIN 10
    
    CRGB leds[NUM_LEDS];
    
    
    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 effect_change;
      int Effect_Change;
      
      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;
    
        int Effect_Change = 255;
    
        //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;
    
          }
    
        // Let the FastLED library know how many pixels we will be addressing
    
        FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds);
    
        // Loop through each of the pixels and read the values for each color
    
        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);
    
    // I added this to detect if the first channel has a value of 255 it will run the effect
      
       effect_change = ( leds[1].r-'0')*100+(leds[1].g-'0')*10+(leds[1].r-'0');
       if (effect_change == Effect_Change) {
        juggle();
       }
    
    
        // 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!
    
        }
    
    }
    
    
    void juggle() {
      // eight colored dots, weaving in and out of sync with each other
      fadeToBlackBy( leds, NUM_LEDS, 20);
      byte dothue = 0;
      for( int i = 0; i < 8; i++) {
        leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
        dothue += 32;
      }
    }
    Attached Images Attached Images
    Last edited by georgeter; 02-09-2020 at 12:51 PM.

  3. #13
    Join Date
    Oct 2014
    Location
    Sauk City, WI USA
    Posts
    1,218
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    with 1 channel first then 53 pixels you need to account for that in your "read" loop. Once you are headed for the read loop, read the Effect byte before proceeding to the pixel reads.

    Or define the Effect channel as RGB but only use values of R.

  4. #14
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    910
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    Are you accounting for Vixen sending Null data (zeros) when there are no effects selected for that element? How does your code know to complete the bouncing ball routine without acting on the Null data being received every 50 milli seconds? I am not a programmer either but I did not see any timer function where the new "juggle" routine is ignoring any new data while it produces bouncing balls for some undetermined amount of time without starting over every time it receives a new string of data?
    Kevin

  5. #15
    Join Date
    Jan 2020
    Posts
    9
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    @MikeCrebs Thanks for the suggestion about just using a rgb as the Effect Channel. That makes it easier for me to read and interpret the data for the time being.

    @kev Yep, you are right I do not have a timer function in place. I did not get that far yet. My first step was to interpret the data coming in from Vixen, then see if I could act on it.

    Is there any way to close this thread? I don't want to waste anyone else's time. I will work on this a little later.

    Thanks guys for your feedback.

  6. #16
    Join Date
    Jan 2020
    Posts
    9
    Post Thanks / Like

    Default Re: Using Vixen to trigger effects in Arduino code

    I was able to trigger the FastLED effect in the Arduino code by adding a RGB element as the 54th led and just monitoring the red value as MikeCrebs suggested. I will play with selecting different effects by adjusting the level of red (255, 254, 253 etc...).

    Here is my final code for the day. Of course it is not bullet proof or well thought out, but it got me to a happy place.
    Thanks again everyone for helping a complete newbie.

    Code:
    // You must download and install the library from http://fastled.io/ 
    
    #include <FastLED.h>
    
    
    // Sets the maximum number of LEDs that this code will handle to avoid running out of memory
    
    #define NUM_LEDS 54
    
    
    // Sets the pin which is used to connect to the LED pixel strip
    
    #define DATA_PIN 10
    
    CRGB leds[NUM_LEDS];
    
    
    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;
    
          }
    
        // Let the FastLED library know how many pixels we will be addressing
    
        FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds);
    
        // Loop through each of the pixels and read the values for each color
    
        do {
    
          while(!Serial.available());
    
            leds[cnt].r = Serial.read();
             if (leds[53].r == 255) {
                  juggle();
              }
            
    
          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!
    
        }
    
    }
    
    
    void juggle() {
      // eight colored dots, weaving in and out of sync with each other
      fadeToBlackBy( leds, NUM_LEDS, 20);
      byte dothue = 0;
      for( int i = 0; i < 8; i++) {
        leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
        dothue += 32;
      }
    }

Page 2 of 2 FirstFirst 12

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
  •