JeremyBlum.com

v3.1

Tutorial 14 for Arduino: Holiday Lights and Sounds

| 135 Comments

This is one that I’ve been excited about for a long time. When element14 asked me to put together a holiday special, I knew just what to do. This episode is the most technically complex so far; it covers non-inverting op-amp circuits, low-pass envelope detection filters, buffers, power management, and some clever programming. Because of the complexity of the project, fellow Cornell Engineer, Brian Schiffer (whom you might remember from this article where we were both featured) co-hosted this tutorial with me. The end result is pretty spectacular – a chain of 50 LEDs reacting dynamically to music. The twist, however, is that the chain propagates color information from the center, resulting in a temporal visualization of the music. The schematics, programs, and parts list are available for download below:

You can download the files associated with this episode here: Arduino Tutorial 14 Files

Source materials for all my arduino tutorials can be found in my github repository.

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.

Update (9/2/2013): The code has been updated to reflect the new naming convention for the Adafruit LED Library.

Update (12/18/2012): Check out this system installed in a Car by Gyurma

Update (12/15/2012): The Adafruit Library has been updated, and will necessitate a small change to the code. Check out this comment thread for more info.

Update (12/2/2012): Some viewers have suggested improvements to this circuit that have worked well. If you’re having troubles with the circuit I presented, try out this circuit, by John Basila. Open Source Education wins again!

Update (6/9/2012): Check out this version made by Steved: http://youtu.be/iYxLQxpBTJ8

135 Comments

  1. Pingback: Looking Back – A (Lengthy) Reflection on Five Years in Academia | JeremyBlum.com

  2. Hey Jeremy,

    Great tutorials! I am an arduino newbie (done a couple projects) and I want to dabble into this one. The breadboard suggested for this project (GLOBAL SPECIALTIES – PB-103 – BREADBOARD) is pretty pricey!!

    Is there a reason you suggest this guy? Can I use a substitute e.g. http://www.ebay.ca/itm/Mini-MB-102-Solderless-Breadboard-Protoboard-830-Tie-Points-2-buses-Test-Circuit-/360752923307?pt=LH_DefaultDomain_0&hash=item53fe8cc2ab&_uhb=1

    Thanks!

  3. Hey Jeremy,

    I have built circuit according to the schematics you provided, however its not working. When I plugin in the headphones into the jack the two leds go out. Having a hard time trying to trouble shoot it. This is what my board looks like.

    http://postimg.org/image/7duxaqgmt/

    http://postimg.org/image/k2aytvb4z/

    • Dave,
      Can you clarify something, because you mention you are plugging in headphones to the jack? The jack on the circuit (the breadboard) is for a line level audio input, it is not an output.

      It looks like your circuit is working because when you plug into the input, the LEDs go out, this is expected behavior because they will now only light up when receiving an audio signal. Try plugging in an ipod or other audio device to the jack and try that. Apologies if I misinterpreted and you already are doing so, in which case try adjusting the potentiometer trimpots (input sensitivity).

  4. Wow it was only that, thanks so much! The proof is in the pudding.

  5. Hey Jeremy,

    I’m a college student at SUNY Fredonia and I need some help with a project. I’m in a Lighting and Sound class and I need to make a prop that lights up for class. This task simply isn’t enough for me. My idea is to make gloves that light up at the tips of the fingers and either change colors or blink to beats in music. Do you have any pointers or ideas that I can do? Also, can I make this setup wireless? As I said, they’re gloves, so I don’t want wires and things to get in the way of the light show and the movements. Thank you so much for reading this and I hope to hear back from you soon! The project is due in a couple weeks so I really do hope to hear back from you soon!

    Anthony Schroeder

  6. Ciao Jeremy,

    I’m writing from Italy and I’d congratulate you on the tutorial.

    Two main questions before to begin the project:

    1) I’m a little bit confuse on the way I can feed audio to the Arduino in order to be processed (minutes 12.23 of your video) . Is it correct if a take the signals and grounds of the two headphone wires and bring them into the arduino in order to be sampled? or I’ve to build and audio jack at the and of the Headphone cable and feed it to Phono Jack you mentioned in the Part list?

    2) May I use another type of led strip to cheape my project? (e.g: http://www.ebay.com.au/itm/1-10M-3528-RGB-LED-Strip-300leds-SMD-Led-light-IR-controler-Power-adapter-/261392401551) Any idea is well accepted!

    Thanks in advance!

    Giorgio

    • Hello Giorgio,

      for your questions:
      1) The Voltage of the sound coming in is very low and cannot really do much. It can work, but you won’t get good results. It’s best if you did the amplification according to the tutorial.

      2) The link you provided shows a led strip that is not addressable, which means you cannot control a specific led in the strip.

      • Hello John,

        thanks for your prompt answer!

        1) Yes my intention is of course amplify the audio signal but I was also wondering if the signal has to be provided hardwired or through the input Jack? This is because in the part list is present an audio Jack which can be used in the board but in the video I cannot see it.

        2) Ok now I see the difference! Maybe I can buy a simpler strip led(or use simple RGB led) but of course I have to modify the code.

        Thanks in advance.

        • 1) No need for an audio jack, you can connect the wire directly to the amplifier.

          • Thank you again John.
            I’ve just bought the necessary components without the part related to the strip led just to see if I’m able to read the signals…I will let you know the progresses.

            Have a nice day!!

            Giorgio

  7. Hello John, Jeremy, folks

    I want to share with you my experience with this project.

    In order to see the DC behavior of the circuit I have removed the parallel RC components between buffer and LED and after supplying with Arduino 5V the opamp, I see the led turned on also without having any voltage in the V+ pin of the inverting opamp. In fact at the buffer input I read 3.62V rather than to have 0V as per my expectation!!

    Is this something missing in my knowledge (like e.g some particular path in the circuit) or it can be something wrong in the circuit connection?

    To meet your needs I posted the schematic with the equivalent voltage I acquired in the circuit and a picture with the actual connections.

    http://postimg.org/image/yr7p70669

    http://postimg.org/image/vln3gsnk1

    Looking forward for you answer,

    Best regards.

    Giorgio

  8. First off, really cool project.

    I built it all and pushed into onto a little breadboard to reduce the size. I have the green and red LEDs flashing to the music. I’m having issues with getting the LED strip to work though.. I’m guessing that it’s because I went cheap and bought this LED strip off of Amazon:

    http://www.amazon.com/SUPERNIGHT-16-4Ft-Waterproof-Changing-Flexible/dp/B00APDU516/ref=cm_cr_pr_product_top

    The power supply is 12v/1Amp, so I cut the LED strip down to about a meter to see if maybe that would help out.. Nope. Still not working.. Does this sketch only work with the Adafruit LEd strip?

    • Update: I changed the power supply so that it powers only the LED strip. I can faintly see the red and green lights in the strip, but changing the gain on either channel doesn’t affect it at all..

      • Chris,
        Unfortunately, the LED strip is a critical piece of the design that you can’t skimp on. This is because it needs to be a Digital RGB strip (where each LED is individually addressable).

        The sketch and library is designed to work with digital LED strips that have the WS2801 chip in them. The Adafruit strand is based on this chip: http://www.adafruit.com/products/322

        I would do a product search for WS2801 LED strip and purchase the right kind. You don’t want the WS2811 (or WS2812b) strips because they require a different set-up (only one data pin & very, very timing specific) which requires using a different library & modified code.

  9. Great project- I’ve thoroughly enjoyed your Element14 videos as well as your book. I’m still new to Arduino and programming. I’ve ordered a ws2811 RGB LED strip from Adafruit- but I note that the strip you use is a ws2801 (different chip and 1 extra wire). My question is- can the opamp you’ve designed also work with the ws2811 strip I’ve ordered? I read that the timing has to be very specific for the ws2811 chip- but since I’m a newb at all of this… that doesn’t mean much to me. Any insight you can offer would be appreciated. I have an idea of a project I want to have music synced RGB LED lights with.. and the type of strip that I’ve ordered would better fit the bill than the ones you’ve used. Perhaps if it’s easier to use the ws2801 with your opamp design then I may be able to find a flat strip that’s ws2801.. the “Christmas tree” type strand you use isn’t practical for what I need- that’s why I opted for the strip I ordered. Thanks in advance to any advice given me.

    • I had some success with switching the code to WS2811. You need download and add the Adafruit NeoPixel library (https://github.com/adafruit/Adafruit_NeoPixel) to your Arudino Libraries folder and then switch out the reference to the WS2801 library in the tutorial code to the NeoPixel one. As far as I can tell, the calls to add the strip, adjust variables and change colors are all compatible with both libraries but I am not sure if it will be exactly compatible. Let us know how you get on.

  10. Hello again- slowly getting closer to working on this circuit. I lucked up and got a free op amp but it’s the LM324AN from Texas Instruments. I’ve tried doing some comparisons of the datasheets for both opamps and I can’t tell a difference between the two. I plan on trying it out with this opamp that I have- any thoughts on if it’ll work or not? I’m completely new to electronics- so there might be a difference that I’m not noticing. Thanks- and thanks Cyma for your reply earlier- sorry I never posted back. But I did get my LED strip from adafruit and now was waiting on the opamp. Really excited to hook my strip up to some music!

  11. Pingback: Arduino新手教程(14)节日灯光和音响 | 观澜小站

  12. hey jeremy,

    why i can’t download your software?

  13. how can i dis tutorial?

  14. good day sir,

    how can download this tutorial?

  15. can i use other software instead of the software you used?

  16. i hope for your immediate reply. because im planning to make this as my project..thank you sir.!!

  17. I am new to this and trying it as i go, i copied your schematics and ran a check on arduino software and gives me an error. i copied the adafruit link you posted to the libraries folder and im not getting it to be clear.

    Arduino: 1.5.6-r2 (Windows Vista), Board: “Arduino Uno”

    sketch_jun27a.ino:20:29: error: Adafruit_WS2801.h: No such file or directory
    sketch_jun27a:31: error: ‘Adafruit_WS2801′ does not name a type
    sketch_jun27a.ino: In function ‘void setup()':
    sketch_jun27a:39: error: ‘strip’ was not declared in this scope
    sketch_jun27a.ino: In function ‘void loop()':
    sketch_jun27a:63: error: ‘strip’ was not declared in this scope
    sketch_jun27a:71: error: ‘strip’ was not declared in this scope

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    This was the error it sent me. if you can help me i greatly appreciate it.

  18. Pingback: Tutorial 14 for Arduino: Holiday Lights and Sounds Spectacular! | Faweiz Video

  19. So I’ve got everything wired up, and the LEDs on the board are working great. I’m was browsing through the Adafruit store, and I happened across this strip: http://www.adafruit.com/products/306. Can this be used (with the new libraries, of course) instead of a WS2801 based strip? It’s a little bit cheaper and briefly reading through the description it seemed like they are pretty similar.

    Thanks!

  20. Hi Guys, I’ve managed to modify take1 sketch to work with ws2812 based 300 pixels 5m LED stripe using Adafruit NeoPixel library. It works pretty well as to my point of view. However I wanted to make take2 sketch workable as well as it is more spectacular. I failed so far with this effort and probably you can suggest on what could be a problem. I inserted series monitor for debugging the same way as in take1 and found out that there is no analogue input reading at both channels despite the pin setup is the same. I suspect that the whole loop cycle is not executed for whatever reason, maybe it is connected with big pixel number and delay parameter should be adjusted in certain way, but I didn’t find it so far by experimenting. Sketch compilation shows no errors, but it doesn’t work, I can attach both sketches I’ve modified if it could help, just let me know.

    • Hi there! The reason of stucking is found. Obviously there is not enough SRAM in Arduino Uno (and consequently others with the same memory banks) to keep the data for all 300 pixels to be showed by the strip. Experimentally I’ve found that max number of pixels is 236 in this sketch, with bigger number it stucks. I think that using of compressed uint massive instead of uint32 before sending to the strip could save somewhat 300 byte of SRAM. Any comment on that?

Leave a Reply

Required fields are marked *.