Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 35

Thread: Sketch to keep lights lit when no in sequence?

  1. #11
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Yes, that's basically it.

  2. #12
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    638
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    Would anyone happen to have an example of a sketch where the lights stay lit when a Vixen sequence isn't running? I would like the elements to stay lit when I don't have a show going.

    If it helps, I am using the Mega 2560.

    Thank you!
    You have a couple of methods to achieve what you want.

    First, assuming that you keep your computer connected to the MEGA and continue to run Vixen, you can create a sequence with all lights on and run it when you want all the lights on. You could run it in the scheduler right before and/or right after your regular show,

    Second, assuming that you disconnect your computer from the MEGA or shutdown Vixen, you could modify the random part of Victor's code to turn on all channels instead of entering the random mode.
    Kevin

    2017 - Pi3 w/FPP controlling 8 ESPixelsticks driving 1250pixels and 3 Arduino MEGAS communicating with ESP-01s driving 96 channels
    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  3. #13
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by kev View Post
    ... First, assuming that you keep your computer connected to the MEGA and continue to run Vixen, you can create a sequence with all lights on and run it when you want all the lights on. You could run it in the scheduler right before and/or right after your regular show...
    Would this scenario use two schedulers, one for the main show and one for the "before or after" a main show?
    Would a scheduler shut Vixen off, thus not sending any data?

  4. #14
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Thank you both for your responses. Is there a "barebones" sketch available anywhere? I'm not a great programmer and I'm afraid to try to remove parts of that sketch if there's a basic one available. I guess I'm wanting the sketch that I'm using but without the random parts.

  5. #15
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    638
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by LightUp View Post
    Would this scenario use two schedulers, one for the main show and one for the "before or after" a main show?
    Would a scheduler shut Vixen off, thus not sending any data?
    I was thinking two different schedules i.e., first schedule from 5-7pm, second schedule from 7-9pm or something like that
    Kevin

    2017 - Pi3 w/FPP controlling 8 ESPixelsticks driving 1250pixels and 3 Arduino MEGAS communicating with ESP-01s driving 96 channels
    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  6. #16
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by kev View Post
    I was thinking two different schedules i.e., first schedule from 5-7pm, second schedule from 7-9pm or something like that
    OK. Does the scheduler shut Vixen off when done?

  7. #17
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    So I tried the following and the test sequence worked but when Vixen plays nothing lights up. Any idea what is wrong with the sketch?

    Code:
    // This code was written by Victor Perez for doityourselfchristmas.com based on the code from Zparticle, Si_champion and Neil Tapp.
     // To adapt the code to your case, just change this top section, with the #define lines.
     
     // Includes the watchdog timer library
     //#include <avr/wdt.h>
     
     // This sets how many channels will vixen be sending. Can be set to any number from 1 to 48 for Arduino Mega, and 1 to 18 for Arduino Uno.
     #define CHANNEL_COUNT 16
    
     // speed for the com port for talking with vixen. From 9600 to 115200. Use the same speed as set in Vixen.
     #define VIXEN_COM_SPEED 9600
     
     // Timeout waiting for serial input before going to random mode (in milliseconds).
     #define TIME_OUT 1000
     
     // If the relays turn On and Off opposite to Vixen sequence, change "#define MODE NOT_INVERTED" for "#define MODE INVERTED"
     #define NOT_INVERTED 0
     #define INVERTED 1
     #define MODE NOT_INVERTED
    
     // which pins control which channels
     // You can change these assignment to use different pins, but be very careful to not repeat the same pin number for 2 channels. 
     // DO NOT use pings 0 and 1, as those are for the serial port to talk to the computer.
     #define CH01 2
     #define CH02 3
     #define CH03 4
     #define CH04 5
     #define CH05 6
     #define CH06 7
     #define CH07 8
     #define CH08 9
     #define CH09 10
     #define CH10 11
     #define CH11 12
     #define CH12 13
     #define CH13 14
     #define CH14 15
     #define CH15 16
     #define CH16 17
     
     int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08,CH09,
     CH10,CH11,CH12,CH13,CH14,CH15,CH16};
    
     int incomingByte[CHANNEL_COUNT];
    
    int i = 0;     // Loop counter
    //volatile unsigned long  timer_a = 0; // new line
    
    //setup the pins/ inputs & outputs
    void setup(){
    
      // enable the watchdog timer with a time of 1 second. If the board freezes, it will reset itself after 1 second.
      //wdt_enable(WDTO_1S);
      
      // specifically for the UNO
      //sei();  
    
    // initalize PWM Channels / Pins
     for (i=0; i < CHANNEL_COUNT; i++){
        pinMode(channels[i], OUTPUT);
      }
    
    // set all the realys to off to start with
    if (MODE == NOT_INVERTED) {
     for (i=0; i < CHANNEL_COUNT; i++){
         digitalWrite(channels[i], LOW);
    
     }
    }
    
    else {
     for (i=0; i < CHANNEL_COUNT; i++){
         digitalWrite(channels[i], HIGH);
     }
    }
    
     testSequence();
     
    // set up Serial according to the speed defined above.
      Serial.begin(VIXEN_COM_SPEED);
    }
    
    void loop()
    {
       if (Serial.available() >= (CHANNEL_COUNT+2)) {
         //wdt_reset(); // resets the watchdog
         //timer_a = millis (); // new line
         int uno = Serial.read();
         if (uno == 126){
           
           int dos = Serial.read();
           if (dos == 33){
       
             for (i=0; i < CHANNEL_COUNT; i++) {
                 // read each byte
              incomingByte[i] = Serial.read();
             }
         if (MODE == NOT_INVERTED) {
          for (i=0; i < CHANNEL_COUNT; i++){
          int value = incomingByte[i];
          if (value <= 127) {
            digitalWrite(channels[i], LOW);
          }
          else {
            digitalWrite(channels[i], HIGH);
          }
          }
         }
         else {
         for (i=0; i < CHANNEL_COUNT; i++){
          int value = incomingByte[i];
          if (value < 127) {
            digitalWrite(channels[i], HIGH);
          }
          else {
            digitalWrite(channels[i], LOW);
          }
          }
         }
    
           }
         }
       }
    // Random mode code. Random mode starts if no serial input has been received in TIME_OUT millisenconds
       //else {
         //wdt_reset(); // resets the watchdog
         //unsigned long diff = millis() - timer_a;
         //if (diff >= TIME_OUT) {
           //timer_a = millis ();
           //int random_a = 0;
           //for (i=0; i < CHANNEL_COUNT; i++){
             //random_a = random(0, 2);
             //if (random_a == 0) {
               //digitalWrite(channels[i], LOW);
             //}
             //else {
               //digitalWrite(channels[i], HIGH);
             //}
           //}
         //}
       //}
    }
    
    void testSequence(){
    
    if (MODE == NOT_INVERTED) {
     for (i=0; i < CHANNEL_COUNT; i++){
       //wdt_reset(); // resets the watchdog
       digitalWrite(channels[i], HIGH);
       delay (500);
       digitalWrite(channels[i], LOW);
     }
    }
    
    else {
     for (i=0; i < CHANNEL_COUNT; i++){
       //wdt_reset(); // resets the watchdog
       digitalWrite(channels[i], LOW);
       delay (500);
       digitalWrite(channels[i], HIGH);
       }
     }
    }

  8. #18
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Okay so I altered some things from my old sketch (changed analog to digital) and added the test sequence. This sketch works, do you guys see anything glaring that I should fix before I mess with it more?

    Code:
    #define MAX_CHANNELS 16
    int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    
    int incomingByte[MAX_CHANNELS];
    
    void setup()
    {
      int i;
      
      Serial.begin(9600); // set up Serial at 9600 bps
    
      for ( i = 0; i < MAX_CHANNELS; i ++ )  pinMode(channels[i], OUTPUT);
    
      testSequence();
    }
    
    
    
    void loop()
    {
      int i;
      
      if (Serial.available() >= MAX_CHANNELS)
      {
        for (i=0; i < MAX_CHANNELS; i ++)      incomingByte[i] = Serial.read();
      }
    
      for (i = 0; i < MAX_CHANNELS; i ++ )    digitalWrite(channels[i], incomingByte[i]);
    }
    
    void testSequence(){
      int i;
    
      for (i=0; i < MAX_CHANNELS; i++){
        digitalWrite(channels[i], HIGH);
        delay (500);
        digitalWrite(channels[i], LOW);
      }
    
    }

  9. #19
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    Okay so I altered some things from my old sketch (changed analog to digital) and added the test sequence. This sketch works, do you guys see anything glaring that I should fix before I mess with it more? ...
    The basic one if you have a power bump on your Arduino board it would lose sync with Vixen since there is no starting frame. A header that Vixen sends would alleviate that to a great extent.

  10. #20
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    So I tried the following and the test sequence worked but when Vixen plays nothing lights up. Any idea what is wrong with the sketch?
    Simple question first. Did you use the header ~! in Vixen Generic Serial setup?

Page 2 of 4 FirstFirst 1234 LastLast

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
  •