1 Reply Latest reply on Sep 7, 2015 11:03 AM by DiegoV_Intel

    Radioshack Tricolor LED Strip

    AllieF

      Has anyone successfully used the Tricolor LED Strip from Radioshack http://www.radioshack.com/radioshack-tricolor-led-strip/2760339.html with the Intel Edison? I tracked down some code that is compatible with arduino for this product, but after attempting it with the Edison and doing some research, I've determined that the architecture of the Edison doesn't support Port Registers. If anyone has any suggestions or solutions to this problem, that would be greatly appreciated! Below is the code Arduino code which I have confirmed does indeed work with an Arduino Uno, but not an Edison.

       

      // ******** 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

       

       

      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},

      };

       

       

      PROGMEM const unsigned long pattern_test_blue[10][10]={

        {0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00},

      };

       

       

      PROGMEM const unsigned long pattern_test_green[10][10]={

        {0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff},

      };

       

       

      PROGMEM const unsigned long pattern_test_white[10][10]={

        {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},

      };

       

       

      PROGMEM const unsigned long pattern_test_comet1[][10]={

        {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},

        {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff},

      };

       

       

      PROGMEM const unsigned long pattern_test_comet2[][10]={

        {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},

        {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},

        {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},

        {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},

        {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},

        {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},

        {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},

        {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},

        {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},

        {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},

      };

       

       

      PROGMEM const unsigned long pattern_test_comet3[][10]={

        {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},

        {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444},

        {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444,0x111111},

        {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0xffffff,0x444444,0x111111,0x000000},

        {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},

        {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},

        {0x000000,0x000000,0x000000,0xffffff,0x444444,0x444444,0xffffff,0x000000,0x000000,0x000000},

        {0x000000,0x000000,0xffffff,0x444444,0x111111,0x111111,0x444444,0xffffff,0x000000,0x000000},

        {0x000000,0xffffff,0x444444,0x111111,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},

        {0xffffff,0x444444,0x111111,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff},

      };

       

       

      PROGMEM const unsigned long pattern_test_rainbow[10][10]={

        {0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000},

        {0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000},

        {0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000},

        {0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff},

        {0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff},

        {0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff},

        {0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00},

        {0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00},

        {0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00},

        {0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000},

      };

       

       

       

       

       

       

       

       

      // ***********************************************************************************************************

      // *

      // *                            Power Up Init.

      // *

      // *

      // ***********************************************************************************************************

      void setup() {             

       

       

        STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use

       

       

        reset_strip();

        //noInterrupts();

       

       

      }

       

       

       

       

       

       

      // ***********************************************************************************************************

      // *

      // *                            Main Loop

      // *

      // *

      // ***********************************************************************************************************

      void loop()

      {

       

       

        send_1M_pattern(pattern_test_red, 10, 500);

        delay(500);

        send_1M_pattern(pattern_test_blue, 10, 500);

        delay(500);

        send_1M_pattern(pattern_test_green, 10, 500);

        delay(500);

        send_1M_pattern(pattern_test_white, 10, 500);

        delay(500);

        send_1M_pattern(pattern_test_comet1, 10, 70);

        delay(500);

        send_1M_pattern(pattern_test_comet2, 10, 70);

        delay(500);

        send_1M_pattern(pattern_test_comet3, 10, 70);

        delay(500);

       

       

       

       

       

       

        while (1)

        {

          send_1M_pattern(pattern_test_rainbow, 10, 70);

        }

       

       

       

       

        /*

      frame++;

          if(frame<=10) LEDSTRIP_PATTERN_0();

          if(10<frame<=20) LEDSTRIP_PATTERN_0();

          if(20<frame<=30) LEDSTRIP_PATTERN_0();

          if(frame>30) frame=1;

         */

        //delay(1);

      }

       

       

       

       

      /*******************************************************************************

      * Function Name  : send_1M_pattern

      * Description    : Transmit pattern to whole 1 meter strip

      *               

      * Input          : pointer to ROM pattern; pattern length; frame rate

      *               

      * Output         : None

      * Return         : None

      *******************************************************************************/

      void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate)

      {

        int i=0;

        int j=0;

        uint32_t temp_data;

       

       

        for (i=0;i<pattern_no;i++)

        {

          noInterrupts();

          for (j=0;j<10;j++)

          {

            temp_data=pgm_read_dword_near(&data[i][j]);

            send_strip(temp_data);

          }

          interrupts();

       

       

          delay(frame_rate);

       

       

        }

       

       

       

       

       

       

       

       

      }

       

       

       

       

      /*******************************************************************************

      * Function Name  : send_strip

      * Description    : Transmit 24 pulse to LED strip

      *               

      * Input          : 24-bit data for the strip

      *               

      * Output         : None

      * Return         : None

      *******************************************************************************/

      void send_strip(uint32_t data)

      {

        int i;

        unsigned long j=0x800000;

       

       

       

       

        for (i=0;i<24;i++)

        {

          if (data & j)

          {

            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");

         

      /*----------------------------*/

            __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");     

      /*----------------------------*/   

            DATA_0;

          }

          else

          {

            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"); 

            DATA_0;

      /*----------------------------*/   

             __asm__("nop\n\t");

            __asm__("nop\n\t");

            __asm__("nop\n\t");   

      /*----------------------------*/      

          }

       

       

          j>>=1;

        }

       

       

       

       

       

       

      }

       

       

      /*******************************************************************************

      * Function Name  : reset_strip

      * Description    : Send reset pulse to reset all color of the strip

      *               

      * Input          : None

      *               

      * Output         : None

      * Return         : None

      *******************************************************************************/

      void reset_strip()

      {

        DATA_0;

        delayMicroseconds(20);

      }

        • 1. Re: Radioshack Tricolor LED Strip
          DiegoV_Intel

          Hello AllieF,

           

          As you said, the code you posted was made for the Arduino UNO architecture (AVR) so it won’t work for Edison. If you want to use your LED strip with Edison you have to write your own code. You can do some research about how the LED strip works and how the signals to control it should be. With that information you can try to write your own code.

           

          Regards,

          Diego.