View Poll Results: Do you use and arduino for your controller ?

Voters
42. You may not vote on this poll
  • Yes

    29 69.05%
  • No

    13 30.95%
Multiple Choice Poll.
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33

Thread: Arduino code for christmas

  1. #1
    Join Date
    Oct 2012
    Location
    Ottawa, Ontario
    Posts
    127
    Post Thanks / Like

    Default Arduino code for christmas

    Here is the code I am currently using with my arduino UNO with the latest software. It is for 16 channels but can easily be changed to 8 and lower if needed.

    If you want to use this for something more or less but don't know how to change this please me me with the subject "Arduino code for christmas HELP" i am glad to help with any project you wan't.

    ~ this code basicly waits for serial data from vixen http://vixenlights.com and tells the lights what to do(on off and sometimes dimming!) .

    I recommend you use SSR's(SolidStateRelays) for this as it can get very annoying!

    16 CHANNLE
    ///COPY AND PASTE THE BELOW TEXT INTO ARDINO SOFTWARE///

    // Matthew Hudson 2012 //
    // * This code lets you use some solid state relays' and your arduino ofcourse to dimm on off lights //



    int Tree1 = 2;
    int Tree2 = 3;
    int Tree3 = 4;
    int Tree4 = 5;
    int Tree5 = 6;
    int Tree6 = 7;
    int Tree7 = 8;
    int Tree8 = 9;
    int Tree9 = 10;
    int Tree10 = 11;
    int Tree11 = 12;
    int Tree12 = 13;
    int Tree13 = 14;
    int Tree14 = 15;
    int Tree15 = 16;
    int Tree16 = 17;

    int i = 0;
    int incomingByte[16];

    void setup()
    {
    Serial.begin(9600);

    pinMode(Tree1, OUTPUT);
    pinMode(Tree2, OUTPUT);
    pinMode(Tree3, OUTPUT);
    pinMode(Tree4, OUTPUT);
    pinMode(Tree5, OUTPUT);
    pinMode(Tree6, OUTPUT);
    pinMode(Tree7, OUTPUT);
    pinMode(Tree8, OUTPUT);
    pinMode(Tree9, OUTPUT);
    pinMode(Tree10, OUTPUT);
    pinMode(Tree11, OUTPUT);
    pinMode(Tree12, OUTPUT);
    pinMode(Tree13, OUTPUT);
    pinMode(Tree14, OUTPUT);
    pinMode(Tree15, OUTPUT);
    pinMode(Tree16, OUTPUT);
    }

    void loop()
    {
    if (Serial.available() >= 16)
    {
    for (int i=0; i<16;i++)
    {
    incomingByte[i] = Serial.read();
    }
    digitalWrite(Tree1, incomingByte[0]);
    digitalWrite(Tree2, incomingByte[1]);
    digitalWrite(Tree3, incomingByte[2]);
    digitalWrite(Tree4, incomingByte[3]);
    digitalWrite(Tree5, incomingByte[4]);
    digitalWrite(Tree6, incomingByte[6]);
    digitalWrite(Tree8, incomingByte[7]);
    digitalWrite(Tree9, incomingByte[8]);
    digitalWrite(Tree10, incomingByte[9]);
    digitalWrite(Tree11, incomingByte[10]);
    digitalWrite(Tree12, incomingByte[11]);
    digitalWrite(Tree13, incomingByte[12]);
    digitalWrite(Tree14, incomingByte[13]);
    digitalWrite(Tree15, incomingByte[14]);
    digitalWrite(Tree16, incomingByte[15]);

    }
    }

    // Copyright 2012(C) All Rights Reserved




    /// COPY AND PASTE THE ABOVE INTO THE ARDUINO SOFTWARE



    ////// 8 CHANNLE
    /////
    int Tree1 = 2;
    int Tree2 = 3;
    int Tree3 = 4;
    int Tree4 = 5;
    int Tree5 = 6;
    int Tree6 = 7;
    int Tree7 = 8;
    int Tree8 = 9;

    int i = 0;
    int incomingByte[8];



    void setup(){
    Serial.begin(9600);
    pinMode(Tree1, OUTPUT);
    pinMode(Tree2, OUTPUT);
    pinMode(Tree3, OUTPUT);
    pinMode(Tree4, OUTPUT);
    pinMode(Tree5, OUTPUT);
    pinMode(Tree6, OUTPUT);
    pinMode(Tree7, OUTPUT);
    pinMode(Tree8, OUTPUT);

    Serial.print("System Ready");


    }

    void loop()
    {

    Serial.begin(9600);
    if (Serial.available() >= 8)
    {
    for (int i=0; i<8;i++)
    {
    incomingByte[i] = Serial.read();
    }
    digitalWrite(Tree1, incomingByte[0]);
    digitalWrite(Tree2, incomingByte[1]);
    digitalWrite(Tree3, incomingByte[2]);
    digitalWrite(Tree4, incomingByte[3]);
    digitalWrite(Tree5, incomingByte[4]);
    digitalWrite(Tree6, incomingByte[5]);
    digitalWrite(Tree7, incomingByte[6]);
    digitalWrite(Tree8, incomingByte[7]);
    Serial.println("System Ready");

    }
    }

  2. #2
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Re: Arduino code for christmas

    Sorry, I don't have an Arduino, would this work for both 8 and 16 channels by changing just the ChannelCount variable?

    Code:
    /// ChannelCount must be > 0 and < 17
    int ChannelCount = 8;
    int PinOffset = 2;
    
    void setup(){
        Serial.begin(9600);
    
        for (int i=PinOffset; i < ChannelCount + PinOffset; i++)
        {
            pinMode(i, OUTPUT);
        }
    
        Serial.print("System Ready");
    }
    
    void loop()
    {
        if (Serial.available() >= ChannelCount)
        {
            for (int i=PinOffset; i < ChannelCount + PinOffset; i++)
            {
                digitalWrite(i, Serial.read());
            }
            Serial.println("System Ready");
        }
    }

  3. #3
    Join Date
    Oct 2009
    Posts
    181
    Post Thanks / Like

    Default Re: Arduino code for christmas

    Finally got the serial / comm port issue resolved using the "serial code" in this thread - thanks.

    I made a "random" effect on two out of eight channels for a test. The problem now is that
    all eighth channels are effected.

    It does not seem that I have individual channel control.

    Help?

    Thanks

  4. #4
    Join Date
    Sep 2013
    Location
    Venus, Texas
    Posts
    1
    Post Thanks / Like

    Default Re: Arduino code for christmas

    Greetings from Texas......This is my first time tryin the blinky blinky and was having a heck of time figuring out how to write code......MANY MANY MANY THANKS for this forum, the DIY guys and especially for your post ... Uploaded your code and BINGO! It worked...Hope this year is better for all of ya'll than last year!!!!!!

    Have a good one and thanks again

    Kyle
    "Whache the shadowmaker"

  5. #5
    Join Date
    Oct 2013
    Location
    Los Angeles
    Posts
    2
    Post Thanks / Like

    Default Re: Arduino code for christmas

    I am going to use it, has anyone tried this, are those code working?

  6. #6
    Join Date
    Oct 2013
    Location
    Gautier, MS
    Posts
    107
    Post Thanks / Like

    Default Re: Arduino code for christmas

    the code looks good, nice and compact. just need more info on interfacing with vixen.... using the UNO what pins do I attached the BreakOutBoard to?

  7. #7
    Join Date
    Oct 2013
    Location
    Northern Kentucky
    Posts
    83
    Post Thanks / Like

    Default Re: Arduino code for christmas

    I am totally new to the programming christams lights scene. I have bought 2 arduino Uno's and 2, 8 channel solid state relay boards( reason is cause I am no good at soldering). Can anyone help with wiring this thing up and also with the programming lingo. I seen the program in this thread and have figured out i'm in the right place for HELP!!!!! Thank you in advance

  8. #8
    Join Date
    Oct 2013
    Location
    Gautier, MS
    Posts
    107
    Post Thanks / Like

    Default Re: Arduino code for christmas

    Dont... are you striving for a music sync'd show or just a set pattern kind of display? The coding is pretty straight forward, you really only need 2 sections: the void setup(){ things that need to be defined} and the void loop() { what you want to do}

    To turn on a specific relay you would, normally, set the specific value to HIGH, and off as LOW. However, if you are using a sainsmart relay board, its reversed.

    Your code should look something like this:

    void setup() {

    int tree1= 0;
    int tree2=1;
    int tree3=2;
    // etc...

    }

    void loop() {

    // do something

    }

    it helps if you have some experience with programming in C, but is not absolutely nessasary. Just follow some of the coding examples and you should be ok. I use instructables.com for ideas and examples, I have learned A LOT(!) from that site( they even have tutorial examples specific to the Arduino)


    Sent from my iPhone using Tapatalk
    ==================================
    "Bother," said Pooh, chambering his last .45 round as the police closed in on him.

  9. #9
    Join Date
    Oct 2013
    Location
    Gautier, MS
    Posts
    107
    Post Thanks / Like

    Default Re: Arduino code for christmas

    and of course, the example above is great also, I am planning on using a slightly modified version (12 channels) for my display this year


    Sent from my iPhone using Tapatalk
    ==================================
    "Bother," said Pooh, chambering his last .45 round as the police closed in on him.

  10. #10
    Join Date
    Oct 2013
    Location
    Northern Kentucky
    Posts
    83
    Post Thanks / Like

    Default Re: Arduino code for christmas

    I was wanting to have it synched to music but i dont have to. I know its not going to be easy. What do you mean by things that need to be defined? Like i said i am very very new to this programming thing.

Page 1 of 4 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
  •