Loading...
Pages: [1]   Go Down
Author Topic: rgb led strip help  (Read 409 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i just got the rgb 1m strip from radio shack today and its controlled with 12v grd and data. i have the example sketches from radioshack but i just want to control a single segment that i cut of the end and be able to change the colors with a pot and turn it on and off with a push button how do i do this im very confused.
Logged

Offline Offline
Sr. Member
****
Karma: 13
Posts: 386
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a Link for us so we can look at the product?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.radioshack.com/product/index.jsp?productId=16306856
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 108
Posts: 6611
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a bit confusing.  If I understand correctly you can only control the strip in sets of three LEDs.  There are 10 sets in a 1m strip.

Each set receives 24 bits. The 1 bits are long (a little more than a microsecond) and the 0 bits are short (about half a microsecond).  Looks like the off time is not significant.

Send 24 bits for as many sets as you want to control.  I would expect the data to get shifted through so the first bits go to the furthest set and the last bits go to the nearest set.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

im just trying to figure out how to control one section of 3 leds to just stay one color and change with a push button or turning a pot and have a off position thats it. can anyone help me with this please. I tried using the switching method but it wont work it only changes on one end of the pot for a small area.

this is what i have so far

Code:
/******************** (C) COPYRIGHT 2012 RadioSHack ********************
 * File Name          : strip.pde
 * Author             : TRS
 * Version            : V1.0
 * Date               : 27/04/2012
 * Description        : Main program body
 ********************************************************************************
 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
 * AS A RESULT, RS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
 *******************************************************************************/

#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

PROGMEM const unsigned long pattern_test_red[10][10]={
  {0x0000ff}

  };

PROGMEM const unsigned long pattern_test_blue[10][10]={
  {0x00ff00}
  };

PROGMEM const unsigned long pattern_test_green[10][10]={
  {0xff0000}
};


const int analogInPin = A1;  // Analog input pin that the potentiometer is attached to



int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output for color


// ***********************************************************************************************************
// *
// *                            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()
{
  // read the analog in value:
  int sensorValue = analogRead(analogInPin);           
  // map it to the range of 8 colors:
  int outputValue = map(sensorValue, 0, 1023, 0, 3); 
 
  switch (outputValue) {
  //off
    case 0:
   send_1M_pattern(pattern_test_red, 1, 10);
    break;
 //red   
  case 1:
   send_1M_pattern(pattern_test_green, 1, 10);
    break;
 //yellow   
  case 2:
   send_1M_pattern(pattern_test_blue, 1, 10);
    break;
 //green   
  case 3:
   send_1M_pattern(pattern_test_red, 1, 10);
    break;

  }


 

 
 
 
 

  /*
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");
      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;
    }

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










Logged

Pages: [1]   Go Up
Print
 
Jump to: