Eoddan

I am a complete newbie to all the code. I have a basic electronics background and decided to learn about the Arduino and start on some basic projects.I bought the LED Strip from Radio Shack just last night. Today, I hooked up the board and strip according to the guide with 12V AA battery pack into the DC barrel socket, Black to GND, Red to Vin, and the Green to A0. I used their sketch from the website, uploaded it and nothing. Rinse, repeat, and still nothing. Then I noticed a brownish black smudge on the first chip under the clear protector. I thought maybe the chip fried so I cut off the first LED segment (as designed) and soldered the leads onto the next contact pads, re sent the code, and no lights. Granted the segments are still together, except the first one. Not sure if this matters?I think the Aduino works, I ran some successful projects recently and the TX and RX light flicker when loaded. Oddly, when I remove the GND the first 3 LEDs/circuit lights up very dimly.Any help would be appreciated. A simple sketch just to make sure the lights and strip work would be a good start.Thanks

//}; This looks like a typo...extra curly bracket in copy pasted code I suspect.

/************************************************************ * One Time Setup. Called once. * Sets up Pin modes, and resets LED strip. ***********************************************************/void setup() { STRIP_PINOUT; // set output pin - DEBUG: should auto detect which mother board for use reset_strip();}

/************************************************************ * Continuously called loop. When the bottom of the function * is reached, this function is called again, repeatedly, * until the end of time. ***********************************************************/void loop() { //Send a pattern from the array above to the chip on the LED strip. //This sends the red LED pattern array, says there are 10 patterns, //and to delay 500ms between each one. send_1M_pattern(pattern_test_red, 10, 500); //Wait a half second. delay(500); //deleted remaining code in here for clarity. Also original arrays are missing.}

/************************************************************ * Send a pattern to the LED strip. * Arguments: * data[pattern_no][10] - A 2D array of 24bit patterns. * pattern_no - size of first dimension of data array. * Second dimension assumed to equal 10. * frame_rate - Delay between changing led pattern. ***********************************************************/void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate){ int i=0; //loop variable. int j=0; //loop variable. uint32_t temp_data; //temporary variable. //Loop through first dimension of the passed in array. for (i=0;i<pattern_no;i++) { // Turn off interupts (timing critical I suppose). //I wouldn't do anything inside this like print outs... noInterrupts(); //Loop through second dimension of the passed in array. for (j=0;j<10;j++) { //Read a double word from the passed in array. temp_data=pgm_read_dword_near(&data[i][j]); //Send the double word to the LED Strip Chip. send_strip(temp_data); } //Turn interupts back on so that the delay below can operate. interrupts(); //delay frame_rate milliseconds between changing to the next pattern. delay(frame_rate); }}

/************************************************************ * Send a pattern to the LED strip. * Arguments: * data - color pattern to send. * * How on earth they expect a beginer to understand this * is beyond me...but I'll explain it all the same. ***********************************************************/void send_strip(uint32_t data){ int i; //loop variable. unsigned long j=0x800000; //bit mask that gets shifted below.// What this does:// Loop through all 24 bits of color (8 red, 8 green, 8 blue), // starting the bit mask: j = 0000000 10000000 00000000 00000000// Use bit comparison ("data & j") of j with passed in data to // see if the 24th bit is one or zero.// If one, set output pin to 1 and wait X, then set back to zero.// If zero, set output pin to 1 and wait Y, then set back to zero.// Finally, bit shift j once to the right to get a new bit mask:// j = 0000000 01000000 00000000 00000000// to use in next loop iteration.//// __asm__("nop\n\t"); is an 'inline assembly' call of the // nop instruction. nop = No Operation. This is done as a hacky way// to get deterministic timing...hopefully the math below is correct...// // X = 18 * nop// = 18 * 1 instruction // = 18 * 1 sec/16,000,000 (16 MHz)// = 18 * 0.0000000625 sec// = 0.000001125 sec = 1.125 microseconds//// Y = 9 * nop = 0.0000005625 sec = 0.5625 microseconds// for (i=0;i<24;i++) // loop through all 24 bits. { if (data & j) // Is this bit a one or zero? { //Bit is a one, so set the output HIGH, and wait 1.125 microseconds DATA_1; __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); // Set output low again. DATA_0; } else { //Bit is a zero, so set the output HIGH, and wait 0.5625 microseconds DATA_1; __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); // Set output low again. DATA_0; } //Bit shift j, once to the right to get a new mask. j>>=1; } }

This code is bad for many reasons beyond those expressed in my comments. If I can I'll get my hands on one of these and write a superior sketch to use as an example.

The main issue (other than clarity for beginners) is that this code is very dependent on the speed of the arduino's processor and is not tolerant of much modification. Be very careful with print outs in this code because it can skew the timing or not work at all when interrupts get disabled.

dlevans

I am a complete newbie to all the code. I have a basic electronics background and decided to learn about the Arduino and start on some basic projects.I bought the LED Strip from Radio Shack just last night. Today, I hooked up the board and strip according to the guide with 12V AA battery pack into the DC barrel socket, Black to GND, Red to Vin, and the Green to A0. I used their sketch from the website, uploaded it and nothing. Rinse, repeat, and still nothing. Then I noticed a brownish black smudge on the first chip under the clear protector. I thought maybe the chip fried so I cut off the first LED segment (as designed) and soldered the leads onto the next contact pads, re sent the code, and no lights. Granted the segments are still together, except the first one. Not sure if this matters?I think the Aduino works, I ran some successful projects recently and the TX and RX light flicker when loaded. Oddly, when I remove the GND the first 3 LEDs/circuit lights up very dimly.Any help would be appreciated. A simple sketch just to make sure the lights and strip work would be a good start.Thanks

Is your DC barrel maybe backwards? I think the Arduino must be center tip negative (plug it in minus the usb cable... if it doesn't come on it's probably backwards) just flip your positive / negative wires. Green -> A0 (analog zero) red to VIN and black to GND the sketch from RadioShack should at least light them up. The brown on one of the chips might suggest it got fried (and if so probably your whole strip is fried)

As far as the code working how I'd like... no. It's not there yet but I've gotten help from a lot of very helpful people.

If you want to try again and get another strip I suggest http://adafruit.com/products/306 from Adafruit. I have both strips (just to play around with) and the Adafruit ones are way better. Code is better, too. They're both around the same price.

dlevans

EchelonForce that explains a lot about the prints... sometimes it would work with them and sometimes only half the strip would light up.

Neither of which were the color(s) expected, though. You don't have to go out and buy one of these I was just trying to play around with it. Like I said on G+ I also have the Adafruit LED strip and it's much better (and more documented) that I'm going to use for a "main" project.

These ones from RadioShack turn on and off (that's about it lol) and will work for a side project I'm going to give to a friend for her kids as a night like of some kind.

Eoddan

Thank you for all of the help. I have had no luck with the Radio Shack LED strip so I'm going to try to return it for another brand. I checked the barrel wiring and it does appear correct with a positive center. I think the burnt chip either happened when I was hooking it up or was bad before I got it, either way I'd rather start on a known good one before I waste anymore time. Thank you very much for the suggestions and code comments.