Show Posts
Pages: [1]
1  Using Arduino / LEDs and Multiplexing / Re: rgb led strip help on: January 07, 2013, 12:11:35 pm
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);
}










2  Using Arduino / LEDs and Multiplexing / Re: rgb led strip help on: January 05, 2013, 11:13:54 pm
http://www.radioshack.com/product/index.jsp?productId=16306856
3  Using Arduino / LEDs and Multiplexing / rgb led strip help on: January 05, 2013, 10:16:54 pm
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.
4  Using Arduino / LEDs and Multiplexing / Re: arduino uno rgb led pot control help on: December 29, 2012, 02:03:46 pm
well for now i simplified it to 7 colors and off and got this working
Code:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int redPin = 11;       // pin that the red LED is attached to
const int bluePin = 9;       // pin that the red LED is attached to
const int greenPin = 10;     // pin that the red LED is attached to


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

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  // initialize the LED pins as an output:
  pinMode(redPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

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, 7); 
 
  switch (outputValue) {
  //off
    case 0:
   digitalWrite(redPin, HIGH);
   digitalWrite(greenPin, HIGH);
   digitalWrite(bluePin, HIGH);
    break;
 //red   
  case 1:
   digitalWrite(redPin, LOW);
   digitalWrite(greenPin, HIGH);
   digitalWrite(bluePin, HIGH);
    break;
 //yellow   
  case 2:
   digitalWrite(redPin, LOW);
   digitalWrite(greenPin, LOW);
   digitalWrite(bluePin, HIGH);
    break;
 //green   
  case 3:
   digitalWrite(redPin, HIGH);
   digitalWrite(greenPin, LOW);
   digitalWrite(bluePin, HIGH);
    break;
 //aqua
  case 4:
   digitalWrite(redPin, HIGH);
   digitalWrite(greenPin, LOW);
   digitalWrite(bluePin, LOW);
    break;
 //blue   
  case 5:
   digitalWrite(redPin, HIGH);
   digitalWrite(greenPin, HIGH);
   digitalWrite(bluePin, LOW);
    break;
 //purple   
  case 6:
   digitalWrite(redPin, LOW);
   digitalWrite(greenPin, HIGH);
   digitalWrite(bluePin, LOW);
    break;
 //white   
  case 7:
   digitalWrite(redPin, LOW);
   digitalWrite(greenPin, LOW);
   digitalWrite(bluePin, LOW);
    break;
  }
  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print(sensorValue);     
  Serial.print("\t output = ");     
  Serial.println(outputValue);   
 
  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(10);                     
}
5  Using Arduino / LEDs and Multiplexing / Re: arduino uno rgb led pot control help on: December 29, 2012, 12:09:44 pm
so i have to code from that site working and im trying to get

if (inputValue =< 23)
ledPins LOW;

in there to turn the pins off under 24 analog read but i keep getting errors
rgb.ino: In function 'byte* hsvToRgb(int, double, double)':
rgb:89: error: 'inputValue' was not declared in this scope
rgb:90: error: expected `;' before numeric constant

what area should i put the if statement?
6  Using Arduino / LEDs and Multiplexing / 4 led strobe/chaser multi patterns and speed help on: December 29, 2012, 08:26:43 am
for my second program im trying is to make 4 sets of leds capable of doing multiple store and chase patterns with the push of a button and change the speed with a pot. i also want to find the easiest way to add new patterns in the code so are there any generators for the pattern portion of the code or a what i can write out codes with out a bunch of delays. i have done lots of looking in to this but can really only find code for the night rider effect which i don't really want cause its only 4 sets. so if you all have any direction on where to start that would be appreciated.

Thank you,
      Koteman
7  Using Arduino / LEDs and Multiplexing / arduino uno rgb led pot control help on: December 29, 2012, 08:18:50 am
i bought my first arduino uno the other day so i'm a noob. I have watched and read tutorials for probably about 12 hours worth so far and ill read another 10 hours today at work for a few of the projects i want to accomplish. first i'm trying to make a RGB led controller for my car. it will have a few RGB LEDs but they will all be the same so i know i only need 3 PWM pins to control them with transistors and i want to have a pot on A0 control the whole color spectrum plus plus off and white at the 2 extremes of the pot. i have the hard ware part down as i'm good with hardware i'm just new to software programming so i'm having difficulty learning this code. any guidance on which libraries i should use? i was thinking the map function for the pot and using say 0-50 for black 50-1000 for colors and 1000-1023 for white.

after looking for similar projects im going to base it off of this.
http://www.skylark-software.com/2011/01/arduino-notebook-rgb-led-and-color_21.html

Thankyou,
       Koteman
Pages: [1]