Could use some coding help.

I have written and tested this code.

int speaker = 2;
int led[] = {
  9, 10, 11};
int pressure = A1;
const boolean ON = LOW;
const boolean OFF = HIGH;

const boolean RED[] = {
  ON, OFF, OFF};    
const boolean GREEN[] = {
  OFF, ON, OFF}; 
const boolean BLUE[] = {
  OFF, OFF, ON};



void setup() {
  Serial.begin(9600);
  for(int i = 0; i < 3; i++){
    pinMode(led[i], OUTPUT);
  } 
  pinMode(speaker, OUTPUT); 
}
void loop() {


  int value = analogRead(pressure) / 4;

  if((value >= 1) && (value <= 150))

  {
    setColor(led, GREEN);
    digitalWrite(speaker, HIGH);  
  }
  else if(value >= 151)
  {
    setColor(led, RED);
    digitalWrite(speaker, LOW);


  }
  else 
  {
    setColor(led, BLUE);
    digitalWrite(speaker, LOW);
  }
  Serial.println(value);
  delay(100);
}

void setColor(int* led, boolean* color){
  for(int i = 0; i < 3; i++){
    digitalWrite(led[i], color[i]);
  }
}
void setColor(int* led, const boolean* color){
  boolean tempColor[] = {
    color[0], color[1], color[2]        };
  setColor(led, tempColor);
}

The issue I have is that I need to use 4 RGB LEDs and 4 sensors, that uses up all of my pins on the Arduino. I have a WS2803 IC that I would like to use for the LEDs but want them to behave the same way as in the code above. Being new to this I am asking for some help on how to write the code to make this happen. I have already downloaded the library for the IC but cant find any examples of how to code it for individual LEDs, not a strip or grid. Thanks for the help.

Have a look at the message at LED RGB 64-control individually - #12 by system - LEDs and Multiplexing - Arduino Forum

That's how to wire it (well, you won't need two chips).

As for coding, it's just a shift register. place the numbers in a variable and shift them out. Think of it as a strip in which you control each LED individually.

I have the wiring down but I cant figure out the coding. I have the concept of how a shift register works but I can't figure out how to write the code and send the bits based on the reading from the pressure sensors.

darbye:
I have the wiring down but I cant figure out the coding. I have the concept of how a shift register works but I can't figure out how to write the code and send the bits based on the reading from the pressure sensors.

Well, you put the bits into bytes. Then you shift out the bytes. Which part are you having a problem with?

Setting up the WS2803. Do I have to use the library and how to use the variable data from the pressure sensors to control the LED color. I have seen examples that would work if I just wanted to light the lights in a certain pattern but nothing like what I am trying to do. As I have said before, I have got it to work straight off the Arduino for 2 LEDs but I dont have enough output pins to do it with 4.

you should go for a pure electronic system where the sensor power the led then