# Web Controlled LED strips

**URL:** <https://community.particle.io/t/web-controlled-led-strips/5745>\
**Category:** Project Share\
**Created:** [July 15, 2014, 1:34pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745 "2014-07-15T13:34:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shocku992](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/shocku992/32/53_2.png) [@shocku992](https://community.particle.io/u/shocku992)\
**Post date:** [July 15, 2014, 1:34pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/1 "2014-07-15T13:34:08Z")

</div>

It’s been a while since I’ve been here. After getting my Bearded Dragon’s cage monitoring working the way I wanted I haven’t really had any other big projects. After finishing college, getting a new job, and moving I’m finally ready to take on my next project.

I’ve got a few RGB LED strips and a nice black and white cityscape canvas picture that looks awesome when it is backlit. What I’d like to do is create a website that allows me to pick any color and brightness of my LED strips so I can change the color of the backlit picture.

Any thoughts or help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [July 15, 2014, 1:59pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/2 "2014-07-15T13:59:55Z")

</div>

This might be useful, wrote it a while ago. Not even close to where I want it to be, but it works. You might get some inspiration 🙂

Jordymoors.nl/spark/spark.rar

How’s your wakeup light going? That’s what I was hoping to make with my strips (25m) 😉

---

<div class="post-metadata">

**Author:** ![shocku992](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/shocku992/32/53_2.png) [@shocku992](https://community.particle.io/u/shocku992)\
**Post date:** [July 15, 2014, 2:17pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/3 "2014-07-15T14:17:13Z")

</div>

That is wonderful! That’s a great start for what I’m wanting to do. Thank you!

The light got put on the back burner for now. I just don’t have the programing background to get it the way I wanted it. I could make it fade in and work with a hard coded time, but the front end is not my specialty. I need to spend some more time with Java before I can get that one finished.

25m!? That should keep you busy for a while. Wow. lol

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [July 15, 2014, 2:46pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/4 "2014-07-15T14:46:53Z")

</div>

Glad you like it :)!

I’m trying to work on the sunrise part, but there are no code examples to be found anywhere on the web. Guess I’ll have to make my own color fade then…

I try to take it one step at a time, the posted code being the first step. I wanted to be able to control my strips from the web, although an actual color picker is yet to be made. I tried to get it working on mobile devices (I’ve got an iPad/iPhone), which is why I used jQuery Mobile. So far so good…  
I was hoping on using the timeAlarms library for setting up the times, but I’ve got nowhere near the skills required to set a time for that through the web. Guess I’ll have to ask @bko for some help on that one 👼  
Making it pretty is last on my list. If I can get it working with some ugly web buttons, I can always throw some CSS on it later 😉

Well, I ordered 50m 60/m 5050 RGB strip, but plan on stuffing around 25m of it in a yet-to-be-made false ceiling. Should provide enough light to get me up 😉 Then, I’d like to put around 6m under my bed, well, because I can…  
I was thinking about putting approximately 8m behind a yet-to-be-made cinema wall, for some sort of static ambilight. But having seen some standalone ambilight solutions, I guess I’m gonna go for one of those 😉  
It’d also be nice to create some automatic stair lights, by putting them under the steps, and activating them with either a PIR sensor, or a light-switch.  
The ultimate goal would be to automate my bedroom, powered by :spark: That’d include the lightning, curtains, sound, television, and my electric bed. Something like a “cinema button” would be nice; lights dim, bed goes upright, curtains close, tv/sound system goes on, media player activates, and the fun can begin 🙂

All those dreams are curtesy of :spark:. Now if only I could program AND have time to do so… A nice heap of cash wouldn’t be bad either 😉

---

<div class="post-metadata">

**Author:** ![wgbartley](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/wgbartley/32/1910_2.png) [@wgbartley](https://community.particle.io/u/wgbartley)\
**Post date:** [July 17, 2014, 3:44am UTC](https://community.particle.io/t/web-controlled-led-strips/5745/5 "2014-07-17T03:44:09Z")

</div>

> [@Moors7](#):
>
> All those dreams are curtesy of :spark:. Now if only I could program AND have time to do so... A nice heap of cash wouldn't be bad either

Let me know if you figure that part out, and sign me up!!!

---

<div class="post-metadata">

**Author:** ![Elijah](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/elijah/32/88_2.png) [@Elijah](https://community.particle.io/u/Elijah)\
**Post date:** [July 17, 2014, 5:04am UTC](https://community.particle.io/t/web-controlled-led-strips/5745/6 "2014-07-17T05:04:35Z")

</div>

Hi everyone! I love the idea of a sunrise wakeup display. I’ve posted a set of R,G,B color lookup tables to use with ws2812b LED strips somewhere on here. They’re 5bit resolution, but still work decently well at converting #rrggbb values into brightness values for the LEDs to reproduce the color picked.

Also thought I would drop some jQuery baesd js here I picked up courtesy of @bko . The function sends a POST request with the innerHTML from an element in a drop down menu. It also rewrites an asterisk next to the currently selected option. (I used it to select modes for a lamp).

```auto
document.getElementById('mode_list').addEventListener('click', pickLampMode, false);
    function pickLampMode (evt) {
      var oldState = document.getElementById('mode_list').getElementsByTagName("a");
      var regE = /\(\*\)/;
      for (var i = 0; i < oldState.length; i++) {
        var newState = oldState[i].childNodes[0].nodeValue;
        oldState[i].childNodes[0].nodeValue = newState.replace(regE, "");
      }
     var _OWL = evt.target;
      var aReturn = _OWL.parentElement.getElementsByTagName("div");
      var lmval = aReturn[0].childNodes[0].nodeValue;
      var lm = "mode=";
      var requestURL = "https://api.spark.io/v1/devices/" + deviceID + "/" + postFunc + "/";
      var terms = lm+lmval;
      document.getElementById('returnVal').innerHTML = terms;
      var upText = _OWL.parentElement.getElementsByTagName("a");
      upText[0].childNodes[0].nodeValue += " (*)";
      $.post( requestURL, { access_token: accessToken, a: terms });
   }

```

id=“mode\_list” is the id of an unordered list `<ul>` containing a bunch of list `<li>` items containing the hidden divs which contain the `lmval` value.

Here’s the HTML:

````auto
<ul id="mode_list">  
            <li><a href="#" id="off" name="lamp_mode">Off</a><div style="visibility:hidden;">0</div></li>
            <li><a href="#" id="torch" name="lamp_mode">Torch</a><div style="visibility:hidden;">1</div></li>
            <li><a href="#" id="color_cycle" name="lamp_mode">Color Wheel</a><div style="visibility:hidden;">2</div></li>
            <li><a href="#" id="lava_lamp" name="lamp_mode">Lava Lamp</a><div style="visibility:hidden;">3</div></li>
            <li><a href="#" id="lamp" name="lamp_mode">Lamp (*)</a><div style="visibility:hidden;">4</div></li>
            <li><a href="#" id="lamp_wave" name="lamp_mode">Lamp Wave</a><div style="visibility:hidden;">5</div></li>
            <li><a href="#" id="lamp_viz" name="lamp_mode">Sound Visualization</a><div style="visibility:hidden;">6</div></li>
          </ul>```

Apologies for the poor formatting. The `<a href>` tags are one of the prerequisites for a drop down menu script, so it might be different for you.
````

---

<div class="post-metadata">

**Author:** ![wgbartley](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/wgbartley/32/1910_2.png) [@wgbartley](https://community.particle.io/u/wgbartley)\
**Post date:** [July 17, 2014, 5:33am UTC](https://community.particle.io/t/web-controlled-led-strips/5745/7 "2014-07-17T05:33:42Z")

</div>

> [@Elijah](#):
>
> Apologies for the poor formatting.

I spruced it up a little for you. If you have large blocks of text, you can wrap them in ``` and ``` (3 backticks on a line, followed by your code, and ended with 3 more backticks). 😃

---

<div class="post-metadata">

**Author:** ![shocku992](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/shocku992/32/53_2.png) [@shocku992](https://community.particle.io/u/shocku992)\
**Post date:** [July 17, 2014, 1:07pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/8 "2014-07-17T13:07:07Z")

</div>

You guys are awesome. My fiancé is in town this weekend so I haven’t had time to do much, but I did do some basic testing. Just ignore the chair backs in the way.

[LED CityScape Testing](https://www.dropbox.com/s/dt1mdoe0alpdtwj/Video%20Jul%2015,%208%2012%2053%20PM.mov)

---

<div class="post-metadata">

**Author:** ![dougal](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dougal/32/20713_2.png) [@dougal](https://community.particle.io/u/dougal)\
**Post date:** [July 17, 2014, 2:03pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/9 "2014-07-17T14:03:54Z")

</div>

If you’re using jQuery anyways, you might as well take advantage of it. I’ve posted a jsFiddle with some simplified JavaScript that takes advantage of jQuery more:

[http://jsfiddle.net/dougal/XrLj4/](http://jsfiddle.net/dougal/XrLj4/)

---

<div class="post-metadata">

**Author:** ![shocku992](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/shocku992/32/53_2.png) [@shocku992](https://community.particle.io/u/shocku992)\
**Post date:** [August 31, 2014, 2:59pm UTC](https://community.particle.io/t/web-controlled-led-strips/5745/10 "2014-08-31T14:59:12Z")

</div>

@dougal Do you mind sharing the code from your Spark?
