Author Topic: DigiSpark RBG LED Strip  (Read 10492 times)

zxzwa

  • Newbie
  • *
  • Posts: 3
DigiSpark RBG LED Strip
« on: October 30, 2013, 01:09:33 pm »
I've been inspired to try DigiSpark due to one video: http://www.youtube.com/watch?v=xm1SXe4LAfg.
It's something I've been looking for a very long time, due to BlinkM was too expensive and too "jailed".
But the author hasn't posted the component list or how he accomplished his project.

I'm a total noob so I was wondering if the community could help me out by identify the components.
And maybe even explain me how the video was achieved?



dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: DigiSpark RBG LED Strip
« Reply #1 on: October 30, 2013, 02:15:34 pm »
You might want to take a look at Adafruit's NeoPixel products:
  http://www.adafruit.com/category/37_168

I've used their NeoPixel Arduino library with the NeoPixel Ring, and it works great. If you're patient, you can get WS2811/WS2812 LED strips cheaper off of eBay. But Adafruit is a great place to start, and their Arduino tutorials translate easily down to the Digispark.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: DigiSpark RBG LED Strip
« Reply #2 on: October 30, 2013, 03:39:45 pm »
Cheapest place to get WS2012 strips is aliexpress.com - this is the website adafruit is probably buying from for their strips and raw LEDs. You can get strips now for about 30¢ per LED from aliexpress, and they ship via fedex/dhl so it only takes a few days to get to you :)

zxzwa

  • Newbie
  • *
  • Posts: 3
Re: DigiSpark RBG LED Strip
« Reply #3 on: October 30, 2013, 04:13:14 pm »
You might want to take a look at Adafruit's NeoPixel products:
  http://www.adafruit.com/category/37_168

I've used their NeoPixel Arduino library with the NeoPixel Ring, and it works great. If you're patient, you can get WS2811/WS2812 LED strips cheaper off of eBay. But Adafruit is a great place to start, and their Arduino tutorials translate easily down to the Digispark.

Amazing! Thank you so much!
I've read a few tutorials and digged some more, I've even read for the first time a schematic, didn't scare me off.

Got a little question though:
I've stumbled upon this picture: http://www.flickr.com/photos/paintyourdragon/8319463876/. This is powered with an external source. Is it possible to power the whole LED with DigiSpark plugged into my USB? If yes, how should the pins be connected?

And as the picture shows, this is just the most basic DigiSpark, without any shields, will that be enough?

Cheapest place to get WS2012 strips is aliexpress.com - this is the website adafruit is probably buying from for their strips and raw LEDs. You can get strips now for about 30¢ per LED from aliexpress, and they ship via fedex/dhl so it only takes a few days to get to you :)

I'm familiar with Aliexpress, even more cheaper is to contact a company at: www.alibaba.com.

Thanks for the tip!
« Last Edit: October 30, 2013, 04:15:24 pm by zxzwa »

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: DigiSpark RBG LED Strip
« Reply #4 on: October 30, 2013, 08:17:34 pm »
Powering via USB, your current will be limited to 500mA, which will determine how many pixels you can drive. If you were to turn them all to full white, you'd only be able to drive about 10 pixels. However, since you will often be running code that is fading and blinking the LEDs, you'll rarely be running them at full power, and even when you do, it's typically only for a brief time. How many pixels can you realistically power? Hard to say. Maybe 30, depending on your usage?

The NeoPixel driver library lets you set a global maximum brightness. Since the lights are typically *very* bright, you might try setting the maximum to half of full power, then you can expect to drive twice as many lights:

Code: [Select]
strip.setBrightness(127);

And in fact, you very well may find that you can go much lower than that and still have sufficient brightness for your needs.


MichaelMeissner

  • Full Member
  • ***
  • Posts: 166
Re: DigiSpark RBG LED Strip
« Reply #5 on: October 30, 2013, 08:25:30 pm »
Note, when you get to higher amounts of neopixels/ws2812, that you will need to probably power the leds separately from the Spark, as it might overwhelm the VIN pin.  It is in the documentation, but in terms of wiring the pixels, they prefer regulated 5v (higher than 6 or 7v can damage the leds).  If you have all of the leds at full brightness, it will take about an amp of power for every 16 lights.  I've run two rings on USB power (0.5amp if you are lucky), but I don't tend to use the lights on all of the time, and because of how bright the leds are, I rarely run them at full brightness.

The led software needs to keep the state of the rings in SRAM.  I believe they use 3 bytes per pixel, and with the Spark having only 512 bytes, you won't be able to make really big strands.

Finally, you want to make sure your wiring is good.  I have two neopixel rings wired up right now with twisted stranded wire (I haven't soldered it yet), and every so often it gets wonky where the last few pixels don't show up.

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: DigiSpark RBG LED Strip
« Reply #6 on: October 30, 2013, 08:30:22 pm »
Oh, and for powering the Digispark and strip via USB:

Just tap into GND and 5V on Digispark's J2 jumper (the 3-pin side) and connect them to the power lines on the strip. And hook whichever data pin you want (I used PIN 1) up to the DIN data line on the strip.

If you decide to try using a non-USB external power supply, just connect the GND and 5V from your power supply to both the Digispark *and* the strip, so that the strip can draw current directly from your power source without going through the Digispark.

I put up an example sketch, which is just the standard NeoPixel strip test sketch, plus my own 'colorwave' pattern driver:

https://gist.github.com/dougalcampbell/7243998

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: DigiSpark RBG LED Strip
« Reply #7 on: October 31, 2013, 02:57:30 pm »
if you use this code instead of adafruit's library https://github.com/cpldcpu/light_ws2812 you will still need a buffer of three bytes per colour, but you can send that buffer out several times. For instance if you have 100 LEDs and want each group of ten to be mirrored with the same colours, you can send a buffer of 10 colours (30 bytes) ten times. If you just want to use the strip as a single light source your buffer can be just one colour which gets sent a few hundred times and not worry much about how many lights you're connecting. Unfortunately the lights will reset if you take more than a couple of milliseconds to send the next colour, so there isn't really enough time to calculate colours on the fly unless you're doing something very very simple like looking up a table or reading a more compact buffer format.

For instance, say you wanted to have a huge game of life simulator with 50*50 lights in a grid. If you stored each light's colour that'd be 2500 * 3 = 7500 bytes - no way that'd work on a digispark! However if you stored each light's state as a bit in a byte, 2500 / 8 that's only 312.5 bytes, totally doable! So you could have a buffer of two colours, black and white perhaps, and scan through a more compact representation of your image outputting each colour. Likewise you could have a buffer of many more colours and look them up by their index in an array similar to how a gif stores colours in a table and then for each pixel just specifies using a single byte which colour in the table to use. This could also be really applicable to scrolling text signs - much of the work spent on the digispark marquee programs for the charlieplex shield could be replicated on a much larger scale - perhaps effectively unlimited! Wouldn't it be cool to see one of those scrolling text signs that wrap around a city building powered entirely by a digispark!

And another little note is that you can connect different strips to each pin of the digispark. If you aren't using the USB capabilities it is possible to connect up to 6 separate strips so if you had a buffer of 150 lights you could calculate the lights values, send them to the strip on pin 0, recalculate, send to pin 1, recalculate, send to pin 2, etc. You could also create and destroy your buffer on the stack instead of the heap, meaning your program could only need to use that memory during the code which calculates and sends the colours out, and leave it free for other things the rest of the time - could be pretty handy if trying to do several things at once.

zxzwa

  • Newbie
  • *
  • Posts: 3
Re: DigiSpark RBG LED Strip
« Reply #8 on: November 03, 2013, 01:07:11 am »
Sorry for the late response.

MichaelMeissner, dougal and Bluebie thank you for your help! I'm confident in ordering DigiSpark, a LED strip and a LED ring. Can't wait to tinker with it!