Taking LED pulses in! Making a color changing light organ synthesizer!

Hey all! So I am trying to mod a synthesizer (Korg Volca Bass) into a color organ thing with RGB LEDs.

I want each key pressed on the keyboard to be a different color on a RGB led strip.

The synth has red LEDs for every note on the keyboard that indicate what note you are playing. (It is monophonic, so no two LEDS will be lit simultaneously). I have been trying to get the Arduino to recognize whether the LED is lit and then output a specific color (via RGB PWM), dependent on which key is being pressed. I can't remove the keypress indicator LEDs from the synth because it is SMT, but I just soldered leads to the anode and cathode of the LED and treated that almost exactly like a button from http://arduino.cc/en/tutorial/button. The only problem was that I wasn't getting a good reading when the key was pressed so I put a capacitor in parallel with the pull up resistor and it works totally fine...for just one key.

Heres what my schematic looks like for the one working note: (i didnt feel like adding all the transistors and resistors for the RGB led)

Code for ONE key pressed:

#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3

const int button1pin = 2; 
int buttonState1 = 0;

void setup() {
  Serial.begin(9600);
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
  pinMode(button1pin, INPUT); 
  }


void loop() {
  buttonState1 = digitalRead(button1pin);
 if (buttonState1 == HIGH) {
   analogWrite(REDPIN, 255);
   analogWrite(BLUEPIN, 255);
   analogWrite(GREENPIN, 0);
 }
  else {
    analogWrite(REDPIN, 0);
   analogWrite(BLUEPIN, 0);
  analogWrite(GREENPIN, 0); 

}
}

The real problem I am getting into is when I want to wire the second LED from the second note into the arduino. I do the exact same thing, except send note 1 to pin 2, and note 2 to pin 4. Now every time i play either note, I get the key 2 color on the RGB LED.

Code for 2 possibilities...

#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3


const int button1pin = 2; 
const int button2pin = 4;
int buttonState1 = 0;
int buttonState2 = 0;

void setup() {
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
  pinMode(button1pin, INPUT);
  pinMode(button2pin, INPUT); 
  }


void loop() {
  buttonState1 = digitalRead(button1pin);
  buttonState2 = digitalRead(button2pin);
 if (buttonState1 == HIGH) {
   analogWrite(REDPIN, 255);
   analogWrite(BLUEPIN, 255);
   analogWrite(GREENPIN, 0);
   }
   else {
     analogWrite(REDPIN, 0);
     analogWrite(BLUEPIN, 0);
     analogWrite(GREENPIN, 0);
   }
  if (buttonState2 == HIGH) {
  analogWrite(REDPIN, 0);
  analogWrite(BLUEPIN, 255);
  analogWrite(GREENPIN, 100);
  }
  else {
    analogWrite(REDPIN, 0);
     analogWrite(BLUEPIN, 0);
     analogWrite(GREENPIN, 0);
  }
}

does anyone have any insights? am i going about this the total wrong way? maybe I am hooking this up wrong? It feels weird to wire the cathode of the synth LED directly to the arduino 5v, but thats how I got it to work... Maybe the code is wrong? I'm just experimenting here. lemme know! im here to learn!

Let me Know few things 1) When you pressed is your Led1 glows or not???

2)Just print your button state and paste it so we can know whether button state high or low

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
Serial.print("Button state:");
Serial.println(buttonState );
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}

When I press either key 1 or key 2 (C or C#), my LED strip lights up. The LED keypress indicator on the Volca Bass synth doesnt light up.

I uploaded the button state program to my Arduino, when I press the either button 1 or 2, I get a constant reading of "Button State: 1" if i dont press either one, it says "Button State: 0"

The issue here is that I need to differentiate between Button 1 and Button 2 (and eventually buttons 3-16 too....).

Maybe a better question would be :

" What is the best way to take an external LED state and get the Arduino to read it?"

i.e. External LED is lit, return 1 to Arduino. External LED is not lit, return 0 to arduino.

I definitely [u]cannot[/u] use light-dependent resistors (aka Photoresistors/photocells) .

I also [u]cannot[/u] remove the external LED from its housing, so I [u]must[/u] solder wires [u]parallel[/u] to it.

DOnt do to many thing @ time. first do with one setup Then we go with second one.

Let take the example one with One LeD. RGB and External LED.

1)When you uploaded the button code . What s status of button you got initially.?? You should read zero . Whenever you pressed key you should see changes to 1. Here make ensure button being detected properly and Led connected in series glows properly

2)Once you make ensure button pressed status is correct . Then Serial.print() status of your .Just add Serial.print with write value. you can see what value it write on serial monitor.

analogWrite(REDPIN, 255);
   analogWrite(BLUEPIN, 255);
   analogWrite(GREENPIN, 0);

After this let me know what you are getting the error

I'd like to suggest a different approach, though it is based on quite a few assumptions:

Trying to directly interface the synth's control of the leds. What I mean is, I am quite shure that they aren't driven by individual i/o ports of the main processor, but instead by some shift register or output multiplexer etc. So maybe by identifying the chip the leds are connected to and studying its PDF you can achieve your goal with less cabling and programmatical hassle.

Quite a shot in the dark, I admit.

AMPS-N: 1)When you uploaded the button code . What s status of button you got initially.?? You should read zero . Whenever you pressed key you should see changes to 1. Here make ensure button being detected properly and Led connected in series.

Yes when button is not pressed I get 0. When button is pressed, I get 1.

Apollinaire, good idea, I will check to see what multiplexing is going on. If I locate it though, how would the signal I am getting directly out of the chip be different than taking the signal off of the LED?

Ok so it looks like the lights are being multiplexed by a LV138a chip (https://www.google.com/url?sa=t&source=web&rct=j&ei=ZU4vVK2kBYuvogTHhYFI&url=http://www.ti.com/lit/ds/symlink/sn74lv138a.pdf&cd=1&ved=0CBsQFjAA&usg=AFQjCNFZvALeImIZIIsxQKUSYFtdfZELgQ&sig2=Zh-PEbjcmTozk7gNKmh2jQ

Im not totally sure where to go from here. Any ideas? I feel like I'm in over my head!