Coding for an LED strip

hey guys! got a coding question regarding an LED strip.
i want my led strip to start at a colro and then slowly cycle through all the colors by changing hue until its on a new color, sort of for an ambient vibe,
im running an arduino uno, a 9v1A power supply and an led strip i got from radioshack ( RadioShack.com Official Site - America's Technology Store )

i tried pasting some hex codes i got from here http://www.nthelp.com/colorcodes.htm but when i posted ALL of them in one set of brackets it just flashed. idk if it matters but the strip has 30 LED's on it.

can someone help me out and SHOW me how to code this (not do it FOR me haha although it would be cool if you could provide an example maybe one or two strings just to get me started :slight_smile: )

oh by the way, its a 3 pin LED strip. got the ground to ground, red to vin and green to A0

did a little research, the chip is a TM1803
really wanna get this up and running, i know it must be annoying for experienced users to have to deal with newbies like me but we have to start SOMEWHERE lol, ive googled and googled and i cant find ANYTHING on how to properly have it fade from one color to another and not just change. is what i want even possible?

According to the comments on the Radioshack page, the software they give is pretty iffy. I would use FastSPI, it's straight-forward, supports the TM1803, and as the name indicates, it's awfully fast.

https://code.google.com/p/fastspi/

Regarding the fading of colors, I'd suggest something like (untested psuedocode):

RGB fromColor = CreateRGB(0, 255, 0);
RGB toColor = CreateRGB(255, 255, 255);
RGB currentColor = CreateRGB(0,0,0);
for(float percentage = 0; percentage <= 1; percentage+=.01)
{
   currentColor.r = ((toColor.r - fromColor.r) * percentage) + fromColor.r;
   currentColor.g = ((toColor.g - fromColor.g) * percentage) + fromColor.g;
   currentColor.b = ((toColor.b - fromColor.b) * percentage) + fromColor.b;
   
   // push current color to LEDs
   delay(100);
}

Hopefully this should get ya started.

thank you very much!!!!
ive heard of fastspi but dont know how to use it! i will do some research and post back when i run into trouble :slight_smile:

One of the pieces of documentation that we're writing for the FastSPI_LED library (and one of the things that was undergoing a lot of changes right up until the last minute) is it actually provides support for this exact thing.

In addition to a CRGB class for RGB data, there's also a CHSV class for working with colors in the HSV space (er, HSV-ish, the color balance is a bit different from HSV to be a bitter better balanced to what we tend to actually see).

To do a simple color fade with all leds the same on the TM1803 on, say, pin 11, the code would look something like:

#include <FastSPI_LED2.h>
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];

setup() { LEDS.addLeds<TM1803, 11>(leds, NUM_LEDS); }
loop() { 
  CHSV colorInHSV(0, 255, 255);
  CRGB colorInRGB;
  for(int hue = 0; hue < 255; hue++) {
    // Make an HSV color for the current hue in our loop
    colorInHSV.hue = hue;
    hsv2rgb_rainbow(colorInHSV, colorInRGB);
    LEDS.showColor(colorInRGB);
    delay(50);
  }
}

Also, for running things on the arduino, if it's an operation you're going to do on each LED, try to avoid using floating pointing point numbers, they are stupidly slow on the arduino. A variety of HSV examples are on the list for the final release, as is documentation on the different HSV conversion options that there will be in the library (3, all fast, but all behaving slightly differently depending on what you'll need/want).

got an error on that code

sketch_jun02a:5: error: ISO C++ forbids declaration of 'setup' with no type
sketch_jun02a.ino: In function 'int setup()':
sketch_jun02a:5: error: new declaration 'int setup()'
C:\Users\RaidenBeats\Desktop\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Arduino.h:117: error: ambiguates old declaration 'void setup()'
sketch_jun02a.ino: At global scope:
sketch_jun02a:6: error: ISO C++ forbids declaration of 'loop' with no type
sketch_jun02a.ino: In function 'int loop()':
sketch_jun02a:6: error: new declaration 'int loop()'
C:\Users\RaidenBeats\Desktop\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Arduino.h:118: error: ambiguates old declaration 'void loop()'
Those those lines{code]void setup() { ...}
void loop() { ... }

is this code correct?

#include <FastSPI_LED2.h>
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];

void setup() { LEDS.addLeds<TM1803, 11>(leds, NUM_LEDS); }
void loop() { 
  CHSV colorInHSV(120,100,100);
  CRGB colorInRGB(800000)
  ;for(int hue = 0; hue < 255; hue++) {
    // Make an HSV color for the current hue in our loop
    colorInHSV.hue = hue;
    hsv2rgb_rainbow(colorInHSV, colorInRGB);
    LEDS.showColor(colorInRGB);
    delay(50);
  }
}

for some reason it wont change the color.

What pin do you have the TM1803's attached to? (The sample code before expects it to be on 11). Also make sure power and ground are hooked up to the strip properly.

i had it in A0 but i put it in 11 and it worked perfect :smiley: thanks