RadioShack Tri Color LED project

Hello everyone, I’m new to the arduino world and have started working on some LED projects. Ultimately what I would like to do is use a series of LED strips to create Christmas lights for next Christmas. They’ll blink, fade, move and change colors… all that.

I’ve gone through several tutorials using LEDs and every project has used the PWM pins, however the TriColor uses A0 as an output. I’m able to get it to work using the sketch that came with the setup. I have a couple of questions.

How do I get the strip to fade (pulse)

and how can I get the strip to work using the PWM pins instead of the analogInput pins?

library and pin designation

#include <avr/pgmspace.h>

// ******** DEBUG ==== should auto config to adapt different mother board *********
//#define DATA_1 (PORTF |=  0X01)    // DATA 1    // for ATMEGA
//#define DATA_0 (PORTF &=  0XFE)    // DATA 0    // for ATMEGA
//#define STRIP_PINOUT DDRF=0xFF  // for ATMEGA
#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO
#define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO
#define STRIP_PINOUT (DDRC=0xFF)    // for UNO

LED display

PROGMEM const unsigned long pattern_test_red[10][10]={
  {0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000},
};

For an RGB LED you can use whatever 3 output pins you want. You just have to make sure the software matches the hardware connections.

Note that the Arduino can only power one or two LEDs. You'll need some sort of driver to power string of LEDs. Some LED strips have a built-in driver.

I'm not sure what you're doing with the array. I see a pattern and it's usually best to generate the pattern in software instead of storing the whole thing.

This LED strip is unique in the sense that it only has 3 wires. -+ and signal. I feed the array to the strip, the strip has 30 LEDs, (10 sections) which is why I have an array of 10. Each row of arrays has a delay of 10ms. The particular array if you follow the pattern has a red pattern moving across the 10 sections. Only the Red LEDs are lit.

the 30 LEDs at full white will produce about .6 amps, so I'm simply using a wall-wart with an output of 12VDC/2Amps.

the 30 LEDs at full white will produce about .6 amps,

No, if anything it consumes 0.6 Amps not producing it.

This LED strip is unique in the sense that it only has 3 wires. -+ and signal.

Then you can not control it with PWM. It needs data feeding to it. There is no the analogInput pins being used, these are changed in the program to be digital outputs.

I've gone through several tutorials using LEDs and every project has used the PWM pins,

That is because the only ones you have read use a different sort of LED strip than you have.

You need to know what sort of chip is used in your LED strip and the use a library that talks to that strip.

Hi, what and where did you get the LED strip, as Grumpy_Mike has said it needs a data string sent to it to control all the things that this strip can do.

The supplier should be able to supply you with links to how to program the strip, or you should be able to Google the part number and get a result.

Can you post a link as to where you got the LED strip, thank you.

EDIT http://www.radioshack.com/radioshack-tricolor-led-strip/2760339.html#.VKZDGvmSxv8 If that's it? There is even a support document AND arduino sketch and library.

Tom... :)

Have you seen this:GitHub - adafruit/Adafruit_NeoPixel: Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

TomGeorge: EDIT http://www.radioshack.com/radioshack-tricolor-led-strip/2760339.html#.VKZDGvmSxv8 If that's it? There is even a support document AND arduino sketch and library.

Tom... :)

yes that is the one. I was able to use the sketch and library. It works great. However, I'm just trying to become familiar with what it is actually doing. Like Grumpy_Mike said, it's converting the Analog Input pins to Digital out, but that doesn't make sense to me.

#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO
#define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO
#define STRIP_PINOUT (DDRC=0xFF)    // for UNO

This piece of code seems to be doing what a pinMode(pin, OUTPUT) should be doing (i'm obviously wrong, because I cannot get it to behave the way I would like to). I would like to change the pin to a digital out so I could use my analog inputs.

LarryD: Have you seen this:https://github.com/adafruit/Adafruit_NeoPixel

Thanks LarryD, I have not seen this. I think I'm going to use this LED strip instead. I see I would have control over each diode which would allow me to use PWM.

First of all , you are posting code snippets. Post the entire code. Second, being that you are new, you seem to be confused about analog input and PWM. You are posting definitions, not code. You haven't posted any executable code. Those are all definitions.

As was already mentioned, the Radioshack ledstrip uses a data packet. (or string).

judemorin: yes that is the one. I was able to use the sketch and library. It works great. However, I'm just trying to become familiar with what it is actually doing. Like Grumpy_Mike said, it's converting the Analog Input pins to Digital out, but that doesn't make sense to me.

An analog pin has special circuitry to be able to measure input voltages, but it can be used like a digital pin. Just use A0 as the pin number, for example, instead of 0 which would be pin D0.

#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO
#define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO
#define STRIP_PINOUT (DDRC=0xFF)    // for UNO

This piece of code seems to be doing what a pinMode(pin, OUTPUT) should be doing (i'm obviously wrong, because I cannot get it to behave the way I would like to).

No. This is doing a very efficient and fast version of digitalWrite(). You could change the macros to call digitalWrite, but that function takes much longer to run and that will affect the very critical timing of the signal going to the LED strip.

I think I'm going to use this LED strip instead. I see I would have control over each diode which would allow me to use PWM.

I think you will find that the RadioShack strip is functionally identical. Download the AdaFruit library, and go through their tutorial, using the RadioShack strip. I bet you'll find that it works. You'll will probably be able to mix and match brands without issues.

Your issue is that the RadioShack code does not appear to be easy to modify. AdaFruit has a very good library to drive these smart LEDs. Concentrate on learning that, it will help you greatly in the long run.

I tried using the example from the NeoPixel and when I execute the code, the first set of LED’s light up then nothing happens after that.

I’m using a wall-wart and using gnd & Vin as my power source (12 V). I’ve verified i’m supplying 12V to the breadboard and I’m using pin6 for my output signal. Any suggestions? Below is the code:

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      10

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
    delay(delayval); // Delay for a period of time (in milliseconds).
  }

judemorin: I tried using the example from the NeoPixel and when I execute the code, the first set of LED's light up then nothing happens after that.

I'm not sure what you're describing. Can you be more explicit? What do you mean by the "first set"?

How are you powering the LED strip? Did you see this page? https://learn.adafruit.com/adafruit-neopixel-uberguide Pay particular attention yo the "Best Practices" and "Powering NeoPixels" sections. The LEDs take significant current, and how you hook them up makes a difference.

There are some configuration items in the begin() call. I don't know if the Radio Shack strip needs different settings. Did you try any variations of these settings (AFTER you verify following the wiring suggestions in the above link.)

This LED strip is NOT the same as the Neopixel strips, those use 5V and this uses 12V. Also the chip used here is the TM1803 which is not the same chip either although it might be similar.

@judemorin:- you seem to be mixing up what PWM is, it has absolutely nothing to do with driving this strip so please forget it, you are only confusing yourself. Also the fact that a pin that can be used as an analogue input is being used as a digital output to control this strip is of no consequence it could be any pin. However, because of the very fast signal timing that this chip demands for correct driving the normal digital write functions are not being used and in its place the faster direct port manipulation is being used. http://www.arduino.cc/en/Reference/PortManipulation The down side to that is it makes it harder to change the pin that it uses.

Grumpy_Mike: This LED strip is NOT the same as the Neopixel strips

Well, then. There you have it.

If you want to keep the Radio Shack strip, then you're stuck with their code, and you'll have to spend a lot more time figuring out what it does.

Or, move on and switch over to the AdaFruit style LEDs (which are available from other vendors as well) as you mentioned in an earlier post:

judemorin: Thanks LarryD, I have not seen this. I think I'm going to use this LED strip instead. I see I would have control over each diode which would allow me to use PWM.

You will find that there is much better support for that library, and a wider variety of products with WS2812 style LED that work with it.

But while you WILL be able to control the brightness and color of each LED individually, you will NOT be using PWM: that is essentially an analog control method for a bare LED (or string of LEDs where all are the same brightness/color.) The WS2812 LEDs within these strips each have a little digital processor embedded in each one: they are controlled by digital data packets that are sent out serially one bit at a time with very precise timing.

Here is a discussion on a comparison between FastLED and Adafruit Neopixel library: https://plus.google.com/112916219338292742137/posts/6AUgfAKWVs5

Very intresting, thanks Larry for pointing that out.