Oct 262012
 

[EDIT] Please check out the newest version of the FX Code (v0.51) with Android Bluetooth Control App and Chrome Control Extension.

This code has been revised and I made a new post about it – please see updated post HERE

[EDIT] If you end up using this code for a project please send me a link/pics/video! I love seeing what people do with this! If you like I’ll post a link to your project on the FastSPI FX – User Coolness post. Also make sure to thank Daniel Garcia (the genius dev of the FastSPI library) on the G+ FastSPI Community.

[EDIT] If you have any requests for certain types of effects I’d be happy to look into it. Just let me know what you’re looking to do and I’ll take a swing.

If you find this code very useful please consider donating a little via paypal. I’m having some ‘financial instabilities’ right now and any little bit would help. And if you need a certain effect coded, a donation would certainly obligate me to get that working for you! Sorry for this, it sort of feels like panhandling and the real credit should go to the library creator, but we do what we have to… Thanks for understanding.

[paypal-donation reference=”FastSPI LED FX Code”]

I’m also grateful for bitcoin donations to: 1K5Yy77ejes2FZrHBG5fns3QAicnwZcduq

fastspijpg

Some LED effects I’ve written for Arduino and FastSPI library.

Mostly written for a circle of LEDs but plenty useful for any configuration.
Code available here… the code

***Here is an update to the FastSPI_2_RC1 – the code

Used WS2811 strip, but have also tested with WS2801.

I’ve only tested this on the duemilanove and nano boards. It’s looking like this does not work on the UNO and I’m not sure about the Leonardo or the new Due.

Several people have indicated problems finding the SerialCommand library – so here’s the version I’m using SerialCommand

Here’s where I found it. Thanks to this guy for the library- Steven Cogswell
http://husks.wordpress.com/2011/05/23/a-minimal-arduino-library-for-processing-serial- commands/

http://youtu.be/Jcs1udKP4rs

 

  98 Responses to “FastSPI LED Effects [UPDATED TO WORK WITH FastSPI_2]”

  1. Looks great

  2. How is the Arduino when it comes to timekeeping? Could you make that into a clock with the color components representing the hour, minute and second hands? (perhaps using gradients, or solid bands; also perhaps sending the hands for a full turn on each of their respective ticks like on that Chronophage clock?)

    • Cool idea.
      Shouldn’t be that hard by adding an RTC module to keep time (otherwise the arduino would loose time on every power off)
      I’d also thought a cool clock could be made by using a servo to turn a mirror to split the beam of a laser for the ‘hands’ of the clock..

  3. good work! Do you known if the fastSpi library allows you to set multiple pins when using WS2811. so could i have two different strips hooked up to do different pins? or does the library only allow you to set one pin?

    thanks

    • …from the FastSPI website
      “Also – important note for the tm1809 chipset. Unlike the other chipsets, the tm1809 chipset doesn’t make use of the SPI core. This means that you can use any of pin 0-13 to drive your leds! Use the FastSPI_LED.setPin(pin); method to set which pin you’re driving.”
      I haven’t tested multiple strips on separate pins but this seems to indicate it’s a possibility.

  4. Hi,
    I bought the item:
    http://www.ebay.com/itm/5m-60-LED-m-RGB-LED-Light-Strip-5V-WS2811-WS2801-Waterproof-Addressable-Color-/150931961150
    but i could not run your code in arduino nano. It was necessary to change the library fastspi?
    Tks,
    Rodolfo (Brazil)

    • The ad lists these as WS2811 (WS2801), which is weird as these require different params in FastSPI. I did have a little trouble with the FastSPI library with the ws2801 at first but a patched build fixed the issue. I had no problems with WS2811 when I used the settings for tm1809 in Fast SPI.
      FYI I’ve tested this on Due and Nano.
      Let me know how it goes.

  5. I’m not getting this serial stuff…
    What do I write in the serial monitor to change mode?

    • Crap…I cannot for the life of me figure out how to input serial commands. It just sits there with SETUP COMPLETE and does not respond to anything I put in.

      • Are you using the Arduino IDE for serial?
        If you see ‘SETUP COMPLETE’ then your receiving serial messages.
        Try loading an example sketch that echo’s the serial input and see if your input is working.
        Something like -http://arduino.cc/en/Tutorial/ASCIITable is good start.

        • Got it working. Not quite sure if it was my terminal program or what, but it works now. Thanks. One other question. I am using the WS2801 in 5m strips with 160 totals LEDs. It will only works up to 156 LEDs and when I go above that point it never gets through the setup loop and just hangs any ideas? I have tested up to 320 LEDs with the FastSPI_LED library and it seems to work great so I don’t think that the library itself is the problem.

          • It chokes on this function:

            void copy_led_array(){
            for(int i = 0; i < NUM_LEDS; i++ ) {
            ledsX[i][0] = leds[i].r;
            ledsX[i][1] = leds[i].g;
            ledsX[i][2] = leds[i].b;
            }
            }

          • Its possible you are out of memory. Update size below with you SRAM available for the chip you are using. Those two data structures you have there look to take up about 1k and depending on the efficiency of your code, you could be above the amount of storage you have available.

            int availableMemory()
            {
            int size = 2047;
            byte *buf;
            while ((buf = (byte *) malloc(–size)) == NULL);
            free(buf);
            return size;
            }

          • Hey Derek, I am not sure if you ever solved your issue of this sketch not working with more than ~150 LEDs. I had your same problem with the Arduino Uno, but I swapped that out for the Arduino Mega 2560 and now I have 300 LEDs (LPD6803) working flawlessly. I think WORKINONIT was correct that the issue was with the limited 2K SRAM on the Uno, so the 8k SRAM on the Mega fixed my issue. I am getting ready to try a total of 600 LEDs now, which I believe should work if my calculations are correct. Just thought you might want to know in case you never solved this!!

          • Yeah it was a memory issue. I also tried the Mega and it worked just fine. I couldn’t get the code that WORKINONIT posted to work unfortunately to be able to test it out.

  6. I’m stupid and was putting , between the m and the mode.

  7. Hi, took a risk I would be able to get this strip to work (newbie to arduino) and thanks to your code and a bit of googling on the pins its working like a treat! Much appreciated. I just stuck 12V and GND onto the strip and then connected Pin 3 off the Arduino Due to DI and it just plain worked! Now to understand why 😉 John

    • Right on, glad it worked!
      but what strip are you using? if it’s ws2801/2811 they’re 5V. I would think 12V would be bright but brief ;-{
      you can run about 30 LED’s from the arduino’s 5V, past that you should use another supply probably.
      Have fun!

  8. The WS2811 strips are available with the chip Integrated into the LED, have you got this to work with this variant?

  9. Hello,
    Thanks for the awesome post!
    How would I go about using this with ws2801 strips? What pins connect to what wires?

    The two links below can replace the broken one in the article.

    https://github.com/scogswell/ArduinoSerialCommand
    http://awtfy.com/2011/05/23/a-minimal-arduino-library-for-processing-serial-commands/

  10. Hi all,
    on a steep learning curve here 🙂 and your code really hits a dry spot – thanks.
    I am wondering tho’ – why use TM1809 settings when the lib supports WS2811 (you just have to edit the setting string)?

    • Hi Soren.

      It seems that the TM1809 and the WS2811 shares the same settings.

      If you look in the library header file: FastSPI_LED.h:

      enum EChipSet {
      SPI_595 = 0x01,
      SPI_HL1606 = 0x02,
      SPI_LPD6803 = 0x04,
      SPI_WS2801 = 0x08,
      SPI_TM1809 = 0x10,
      SPI_WS2811 = 0x10,
      SPI_TM1804 = 0x10,
      SPI_LPD8806 = 0x20,
      SPI_UCS1903 = 0x40,
      SPI_SM16716 = 0x80
      };

      you’ll see that both types are initialized with 0x10.

  11. […] And here’s a blog post describing their use.  […]

  12. Hey

    I tested your Code with an Arduino Pro Micro (Leonardo). It was hard to get the right Pin. With the actual Libary, its working.

    One thing: If u want to switch Modes, u have to boot the Arduino with Mode 0 (int ledMode = 0;), not in Demomode. In Demo Mode, u cant put in some, the Arduino is not responding to your Input. So switch to Mode 0 at Start, connect with Serial – and it works.

    So for all, where the serial command not work ^^

    Is it possible, to switch the Modes with a PPM SIgnal, instead of serial?

    Want to use it with my RC Plane and switch the Modes with my Radio Control (Graupner MX-20).

  13. […] Going to try this guy's code, he seems happy and lots of google searching proves it should work: http://funkboxing.com/wordpress/?p=1366 As for your helmet, wow sorry it won't fit. You could sell it as is with the working LEDs for an […]

  14. Thanks a lot for that article, I’m enjoying the sample code and driving about 140 pixels on my arduino(I have a 60 led/m 4m strip that I bought in china for cheap). More and I run out of memory and/or power (5V 3A).
    Looking forward to doing my project, the “bounce” function will prove very useful.
    For those who might be reading and looking how to use the mode switcher, open serial (make sure to select something for a line end) and type for example: “m 4” *Enter*. (separate m and the mode with a space)

  15. Hi, thanks for sharing your great work. I wonder if there is much that must be changed to last FastSPI_LED2 to work?
    Thanks

  16. Tape S2801 connects to Arduino to pin 11 and 13. Sketch does not work. Please tell me which lines in the sketch should be changed and how? Here’s the problem –

    #define PIN 3
    //#define PIN 4

    ?

    • Line 42 of the sketch should be changed to “What do you get if you multiply six by nine?”
      This will answer all your questions.

  17. Great info here. I’m fairly rusty using c and am having a bit of trouble getting this to compile.
    I’ve dropped the include files from above in the hardware\arduino\cores\arduino folder but still get erros when tryhing to verify the code. I am getting these errors :

    FastSPI_Demo.cpp.o: In function `__static_initialization_and_destruction_0′:
    C:\arduino-1.0.4/FastSPI_Demo.ino:45: undefined reference to `SerialCommand::SerialCommand()’
    FastSPI_Demo.cpp.o: In function `pacman(int)’:
    C:\arduino-1.0.4/FastSPI_Demo.ino:755: undefined reference to `FastSPI_LED’
    C:\arduino-1.0.4/FastSPI_Demo.ino:755: undefined reference to `FastSPI_LED’
    C:\arduino-1.0.4/FastSPI_Demo.ino:755: undefined reference to `CFastSPI_LED::show()’

    I’m certain it’s me doing something silly here, but I can’t get any further. Anybody got an pointers please ?
    Thanks
    Phil

    • Looks like it’s not finding the SerialCommand and FastSPI libs
      I believe the includes should be placed in the sketchbook folder in /libraries. Try that and let me know what happens.

      • I worked this bit out. I didn’t put the .cpp files in there as well, just the.h files…. Anyway, it compiles and uploads, says Setup Complete, but doesn’t do anything else. Adding serial print lines shows the code is looping, but nothing lights up. I have a 60 led 1m WS2811 strip.
        A shame, as I am hopefully going to build a fancy clock.
        I read somewhere there is problems with the timing on these strips, do you know anything about that ?

        • Just a few thoughts
          – what arduino board are you using?
          – do you have the code set to use TM1809?
          – is your data pin on a PWM capable pin?
          – also try playing with setDataRate() 0-7
          – have you tested the strip another way to see if it is functional?

          • Thanks for your help up to now.
            As said, I’m VERY rusty on C code having been used to the pleasantries of VB and C#.net in recent years 🙂
            I’m using an UNO with the same settings as your code above, so yes, it’s using TM1809 and Pin 3.
            I tried a couple of different values (0,3, & 7) but still got no output. I’ll try them all tonight.
            It’s responding to the set mode command, so the sketch is running fine,
            The power is coming from the Arduino board via the USB, so I’m only trying the first 5 LEDS.
            I tried a new sketch with the bare essentials of you code in them, but I have now tried any other code to try to see if it works. Can you point the way to a simple, drop-upload-test code I could use ?

            Many thanks for you help so far, I appreciate it.

          • You could try a demo sketch from the FastSPI library.
            Another thought- are you certain these are 5V, not 12V strips? I’ve heard of there being 12V WS2811 out there.

          • None of the demo sketches work.
            I’ve tried the fastSPI, the new V2 FastSPI, the Adafruit NeoPixel and the code from Alan Burlison. None of them work.
            The strip itself has 5v written on it. I tried nudging the voltage up and some of the leds came on, but not being driven by the UNO.
            I guess I must have just got a faulty strip, or just be plain unlucky.
            It came fro mthe US, as I can;t get them in the UK yet, so it will cost too much to send it back for a refund. Maybe I can strip it down for another project later.
            Looks like I’ll have to go back to discrete LED and 595’s. Bummer…
            Thanks anyway

  18. Hi, just a little update.
    I bit the bullet and ordered another ws2811 led strip. This one worked fine on my UNO.
    So I guess the first one was broken.
    Thanks for your help and your code.

    • Excellent, glad you got it working and thanks for the update, now I know it works with UNO also.
      Sorry about the bad strip 🙁

      • OK. Thanks for you help anyway.
        This strip works fine, but the LED seems to be inverted. i.e. RGB 0,0,0 is white, RGB 255,255,255 is off.
        Your Police Lights, for example, are Yellow and Cyan, so the RED and BLUE switched off !!
        Strange 🙂
        Least I get light from it.
        I’m trying to work ok the code to invert it all, rather than each call.

        • Yes, the RGB sequence seems to be different in every strip I get.
          This is the line you’ll need to adjust.

          //-YOU MAY HAVE TO PLAY WITH THE R,G,B ORDER OF THIS TO SUIT YOUR STRIP
          struct CRGB { unsigned char g; unsigned char r; unsigned char b; };
          //struct CRGB { unsigned char r; unsigned char b; unsigned char g; };
          //struct CRGB { unsigned char b; unsigned char g; unsigned char r; };

          • The RGB order was correct, but I had been playing around with the timings in the fastspi.h file when trying to get the old strip working.
            I had inverted the nop_short and nop_long values. That made the colours inverted.
            Once put back, then everything is working great.
            Thanks again.

          • Right on, glad to hear it’s working finally!

  19. Just wanted to say thanks for sharing.

    Your code worked straight out of the download folder 🙂

    Nice effects!

  20. How do I wire the LED strip to the Arduino ?
    Can you point me to a circuit diagram ?
    I have a Nano V3.0
    Thanks, Geeorg

  21. WS2811 LED digital strip from Aliexpress.
    Arduino Nano V3.0
    Can I wire the pixels data-in directly to the Arduino (what pin) or do I need a buffer or something in between ?

    Georg

  22. Has anyone make it work with the Arduino Uno? I’m using a WS2801 strip. I tried to change the data pin from various positions but I can’t make it work.

    Which pin is the clock? I’ve noticed the code says pin 13 but it doesn’t work.

    Thanks

    • I’ve never used the Uno personally so I can’t speak from experience. But some comments from other indicate it works. The demo was made with WS2811 which has no clock pin.

      Here’s some info on the Uno Pins
      http://arduino.cc/en/Reference/SPI

      From what I can tell the sclock pin should be 13. Have you changed with data rate to see if that helps?

  23. […] And here’s a blog post describing their use.  […]

  24. Works like a charm with a WS2811-string using a Teensy 3.0, and I’ve also managed to learn a lot by just going through the code. Thanks for sharing these!

  25. Would there be any way to control the colors/hue/brightness using an interrupt? For example, I am trying to port this sketch to your effects, but can’t figure out how I would send the color values to the various functions using the fastspi_led2 library.

    Any suggestions?

    Oh, and thanks for sharing your effects – they’re awesome!

    • I’ve only interrupts for buttons so I’m not sure. There is currently no function to accept serial commands to change individual LED colors, wouldn’t be hard to implement though. The function set_color_led will do that. You don’t even need that function though, just feed the values you want into the array index you want to change. Hope that helps.

      • You do have code for a button interrupt to change the color? I’m using a 5-position joystick/switch. I am able to turn the strip on/off and change the effects, but don’t know how I would change the color.

  26. […] alles an Arduino angeschlossen und ein Sketch von FUNKBOXING zum Testen drauf und siehe da, es […]

  27. So far having much better luck with the original FastSPI library using my 10 meters of WS2801. I got the FastSPI2 library to work but it was reseting the Uno randomly. When I did get it to work, it wasn’t nearly as fast on some simple test patterns. I must be doing something wrong but I cannot figure out what.

  28. Hello,

    I have written some simple sketches for the fastSpi2 library and have used them with a 300 led strip . i have not been able to get your ode working on an UNO.

    do you have access to an UNO arduino? i would be willing to pay for you to port this code to that platform.

    • I don’t have an UNO on hand for testing but I’ve had some notes from other users that suggest it should work.

      I’d be happy to help get it working. Can you send me a link to where you purchased the strip so I can check them out and also please tell me how you have the pins arranged. Thanks!

      • Let me get that information, but first I am going to try the hardware SPI and associated pins. right now I am using pins 4 (D) and 5 (C) with software SPI. the software SPI works for my sketches but maybe not for your sketches .

  29. I am using hardware SPI pins on my UNO and your code send setup complete to the serial terminal. it fills the entire strip of 32 – LPD8806 LEDs with white. After about 10 seconds the full strip or half of the strip changes to various colors with occasional blinking at the beginning of the strip.

    I guess i can debug the code on my setup.

    thanks

  30. Hello,
    all very nice, bat i have problem…
    Manual mode not function, why?
    In the serial monitor I push the button m, but remains in demo mode …
    What I’m wrong?

    • Hey Antonio. Thanks so much for the donation!
      Select the mode by typing m XX (XX is an integer, use the space)
      Let me know if this works for you, if not, please use the contact form and I will try to work the problem for you. Thanks again!

  31. Hi, since the update to FastSPI 2, where is the function to define which data pin to use, when using WS2811? I am using an adafruit flora, and I want to use D6.

    • The pins are defined in the setup command

      LEDS.addLeds(leds, NUM_LEDS);

      Where in this case the ’11’ is the pin number. You may also have to mess with the order of R-G-B (here is is GRB) to get the colors right.

      Hope this helps!

      • oops, the formatting didn’t work right so the 11 and GRB don’t show up in the reply for some reason… but you can probably find the correct line in the code, it’s in the setup function.

  32. I am not techie at all and would be interested in talking if you are looking for some small work projects. Fritz

  33. […] is a revision of the original FastSPI LED Effects Examples I wrote awhile […]

  34. Hi, is it possible to change the startingnumber for the ws2811 strip? I’m building a clock (60 led’s) and need to have the strip start with 1 instead of 0 to make writing code (modulo) so much easier…

    • I don’t know if there is a way to change the starting index of the strip array, but it should be pretty easy just to do all the calculations however you need, then just always address index-1.

  35. Hi, is it possible to adress more than 150 Leds? Everytime I am setting the LED_COUNT to anything above 150, no leds are lighting up anymore. Michael

  36. I’m a semi beginner on led strip programming. do you think this code will work with my neopixels (WS2812B) running off a Trinket?

  37. it is very great ,i will build my own project ,but use apa102 apa104 led strip to replace the led pixel

  38. Hi im having arduino mega2560 how could I use this code . ie which pins to use plz mention can u plz show a wiring diagram.

  39. Just finishing up a project to add LEDs (WS2812) to the interior of my taxi, The Land Yacht. LED Strips around all the windows, and a “Disco Floor” style project for the floor, all running your code. Each window and each segment of the “Disco Floor” is running on its own Funduino Pro Mini http://www.topuniquebuy.com/ebay/AR/Pro-Mini/Pro-MiniU1.jpg. That means including the EL Wire project on the ceiling, there are 11 Funduino’s running the show in my taxi.

    Video forthcoming.

  40. […] WS2812_Ansteuerung Library für Teensy und sehr viele WS2811 Ansteuerung mit ATtiny 8MHz funkboxing.com: FastLED Effects bascom-forum.de: RGB-Leds-WS2812B für unterschiedl. Taktfequenzen (8, 9.6, 16 MHz) ATTiny10 und […]

  41. hello, its possible to run this demo on an teensy 3.1 ?
    ive a problem – it doasnt compile on Teensy
    on arduino uno it compile but its not running 🙁

    maybe you can help me – maybe anyone can send me the file for running it on teensy 3.1

  42. Hi. How to create Effect knight rider? https://www.youtube.com/watch?v=HFqLOHlry7s

  43. How to create Effect Knight Rider from FastLed.h?
    https://www.youtube.com/watch?v=HFqLOHlry7s

  44. hi there, look at this.

    https://www.youtube.com/watch?v=jPDMc6gYAvk

    It is possible with FastLed?
    How do?

  45. Hi there,

    It works fine with Nano v3. I have a string of 600 neopixels LED, when I define the LED_COUNT to 600, it runs out of RAM, the max I can enter is 150 LEDs, even at that level I get an error saying it could be unstable. How can I make this scrip to work with 900 LED which is the number I am planing to use for a XMAS light around the house?

    Thank you.
    Alex

  46. Hi, I am rather new to coding, but enjoy Arduinos and love your LED control. It is exactly what I have been planning on doing for a “time machine” lighting project. However, I am puzzled by how to operate your code with an RGB LED strip. Can you advise? Will be happy to donate. Thanks!

  47. I get “Setup complete” but nothing seems to be working on the strip. Using pins 11 & 13 for clk and data.

  48. I am also making a clock with the help of aurdino uno and i am giving power of led to uno boad and the board is unable to reset and ‘RTC’ is off after the 3 seconds the clock is off. if any substations regrading it post it

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.