Jump to content
C4 Forums | Control4

Changing all the LED colors in the house, how I programmed it


jbs

Recommended Posts

I've posted about this in a few threads and gotten a few questions about it. Since it has been one of the most time consuming elements of my C4 programming, but also one we like the most, I thought I'd explain how I eventually went about doing it, in hopes that it's useful to others.

The basic idea is that I wanted all the LEDs in the house to show particular colors depending on whether the alarm was set to disarmed, home or away. At first, I started to program it into the "Device" of the Security System, but given the complexity of the program I decided I'd rather separate it out into another variable and therefore be able to invoke it from elsewhere as well.

At first, I was going through and defining, for each of our 70 lights, and for each of the 3 color schemes, Top On = Blue, Top Off = Black, Bottom Off = Blue, Bottom On = Black. Doing this for 70 lights, 3 colors and four LED states (TOP-ON, TOP-OFF, BOT-ON-BOT-OFF) was going to mean nearly 1000 lines of code, and programming the LEDs is not quick, there's much more of a lag time in Composer for me when I'm doing LEDs than when I'm doing light states. So, after kicking it around for awhile, I came up with something I liked better. I'm just going to show the top few lines of each chunk of code, since the overall thing is pretty long.

First, I created a numeric variable called "AlarmState". I went into the Security System Device Event and added a line of code to each of the three Arming States:

c48qc4.jpg

c46zm7.jpg

c47eo7.jpg

Next I created a variable called LED_Color and in the programming for the variable "AlarmState", I added these commands:

c49ly4.jpg

My reason for separating these out so much is to make the code more useful to me elsewhere in my project. If I ever decide that I'd rather have Green be Away and Blue be Home, I can just change two strings in the programming for the AlarmState variable, rather than having to drag 100 lines of code back and forth.

Similarly, if I want to use the LED Colors elsewhere, say to announce that the garage door is open, all I have to do is change the LED_Color variable, not go mess with the AlarmState variable.

OK, now we get into the real heavy lifting . . . In the programming for "When LED_Color variable changes", there are four main IF statements, each checking for a particular color in the string of the LED_Color variable. For each of them (Black, Navy, Green, Red) it now only takes one line of code to set ALL LEDs equal to that color:

c410vv4.jpg

c411au1.jpg

c45jn4.jpg

^^ (The stop command at the end of the RED section is intentional)

c46mv8.jpg

The reason it sets ALL LEDS to the chosen color, is that after these IF statements it then runs through this code last:

c47bz6.jpg

which sets the TOP-OFF and BOTTOM-ON for all switches to BLACK, except in the case of the RED setting, where I wanted to leave top and bottom set to RED.

The effect, then, is that when the alarm changes, generally the top and bottom LEDs on all the switches will change to the new color, and then the top OR bottom of each switch, depending on its state, will go to black.

The other thing I really like about this method, is that if I decide I want something else, like a garage door left open, to be indicated by a Yellow light, all I have to do is add one line of code for each of the switches, rather than 4 lines.

Pheww, OK, that was really long. Hopefully SOMEONE out there will find it useful! It really is one of the most handy little bits of programming in our house.

As always, if there's a simpler / more elegant way of doing this, I'm always interested!

--Jason

Link to comment
Share on other sites


  • 2 weeks later...

Jason,

If it's not too much trouble could you PM me the whole programming sequence. This is a great idea, to be able to visually see what state the alarm is in. Especially when you set the alarm to STAY at night and then forget to disarm it in the morning before you step out the door in the morning. Great Job!!! I can't imagine how long it took to do all the programming.

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Jason,

I would also be very interested in the complete program.

Tonight I scanned the entire forum from past to present

and this is one of the best ideas I've seen.

Since this is my first post, my email is labradley at mindspring.com

Thanks,

Larry

Link to comment
Share on other sites

im hoping in future releases of composer they let you do radio buttons for multiple selctions of devices, sorta like a batch update. apply to... then check boxes... would save a lot of this.

Link to comment
Share on other sites

  • 4 weeks later...

Jason,

What did you do for the 2 button keypads? In the programming for the 2 buttons there isn't an option for top/bottom led. I've got 12-15 of them and can't seem to get the led's to change with all the other switches and dimmers? Thanks for your help!

Link to comment
Share on other sites

I don't have any 2-button keypads, so I can't answer this one from experience, but we do have a lot of 6-button keypads and I know those allow for programming the color of the LEDs. Can someone else confirm whether 2-buttons allow for LED color programming? I would tend to suspect that they would, but maybe it's in a different place.

Link to comment
Share on other sites

Maniac,

In Programming, after you select the event look on the action tab select the 2 button keypad you want to change the LED. Click on the top of the Keypad picture and click on the LED Color radio button and choose the desired color. Do the same for the bottom LED. Make sure that keypad managed is unchecked under system design for all the keypads you want to change the LEDs programmaatically. Hope that makes sense.

Michelo

Link to comment
Share on other sites

I noticed that the 2 button keypads actually change to the color I want however, they change right back to the default color right away. The 3 & 6 button are fine, they do exactly as I want them to. I've rechecked the programming to see if there was an error somewhere, but nothing that I could find. Any thoughts? I also confirmed that the managed check box is unchecked on all of the keypads.

Link to comment
Share on other sites

Hey, everyone. I've gotten a lot of requests for the "full code" or full programming of the setup above. The thing is, there's nothing in the programming that's not reflected in the screenshots above, so there's really nothing more to send. The only thing I clipped out above is the same code for about 60 more identical dimmers, and I only did that because the screenshot program won't scroll through multiple pages. But I screencaptured the top and bottom of each block of code so that you could see all the important parts.

If there's something else that's missing, by all means let me know, but the actual string of codes is incredibly repetitious, and difficult to screencap, so what's posted was intended to convey all the key parts. Let me know if I'm misunderstanding the requests!

--Jason

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.