(LED's) Need help double checking some code/project

This is the current setup of my arduino board and bread board. Click here What the goal to this project is to have my LED's flash with the music from my phone. If you click the link above it'll show you the setup i'm trying to duplicate. I believe I have it all set up but I am running into a little bit of a problem. The LED's are not turning on with or without the music. This is the current code I have uploaded into my Arduino Uno Code Here. What does happen is when I click tools > Serial Monitor that it is in fact reading the music from my phone but the LED's are not turning on. So I need some help finding what I've done incorrectly for these not to flash.

 /* David Wang
 * Code that takes audio input from a 3.5mm cable
 * and flashes an LED strip based on the frequency
 * of the music.
 *
 * HUGE thanks to the arduino community
 * If you see your code here, I owe you my gratitude
 *
 */
 
int analogPin = 0; // MSGEQ7 OUT
int strobePin = 2; // MSGEQ7 STROBE
int resetPin = 4; // MSGEQ7 RESET
int spectrumValue[7];
 
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
 
// LED pins connected to the PWM pins on the Arduino
 
int ledPinR = 9;
int ledPinG = 10;
int ledPinB = 11;
 
void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
 
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
 
  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}
 
void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);
 
    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
 
 
    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
 
    // Remove serial stuff after debugging
    Serial.print(spectrumValue[i]);
    Serial.print(" ");
    digitalWrite(strobePin, HIGH);
   }
 
   Serial.println();
 
   // Write the PWM values to the LEDs
   // I find that with three LEDs, these three spectrum values work the best
   analogWrite(ledPinR, spectrumValue[1]);
   analogWrite(ledPinG, spectrumValue[4]);
   analogWrite(ledPinB, spectrumValue[6]);
}

Had a quick look at that Fritzing picture. Wow.

RGB LED anode connected to V-in (assuming USB supply).
No LED current limiting resistors.
10k resistors from drains to ground??
All wrong, and dangerous for the onboard 5volt regulator.

Didn't even look at the audio side.
Leo..

Did you type your code in italics :smiley: You can edit your post and add code tags so the forum software does not mangle your code.

Type
** **[code]** **
before the code
Type
** **[/code]** **
after the code

My serial plotter and monitor are both reading the music coming from my phone, but when I play music the LEDs are not flashing or turning on at all. Please help :confused:

Give more details of your leds, including part numbers or a link to the data sheet or page where you purchased them. Also part numbers for the transistors you are using.

PaulRb if you go to that very first link above (click here) then it'll show you the parts list in which i bought and then the diagram of what i have set up!

Ok, what happens if you connect one of the r,g,b connections from the led strip to ground? You should be able to get the strip to light up either red, green or blue. Test all three.

Next, connect an ordinary 5mm led + series resistor (eg. 330R) between one of the Arduino pwm outputs and ground. Does that light with the music playing? Test all three pwm outputs.

Ok Paul, I tested all the r,g,b connections and the only one that was able to show light was the color red, but it was very very faint. I then cut a new strip to see if it was just the strip that was failing but it gave the same results. I know have them plugged in how the diagram shows and still the Red LEDs just remain on at all times. I have plugged my phone in and played music and turned my music volume all the way up and just the Red comes through faint still but it does flash very very faintly. Not sure what i'm missing now or what to do. :confused:

Ok I have found the solution to having them being fully bright! Instead of powering them to 5V, I now have them power to VIN. But now I have the problem to where they are constantly on when the music is paused. Is there a way to have them turn off while the music is paused? Also what part in the Arduino Code can i change what color comes in at what frequency?

What do the numbers on serial monitor show when music is paused? Maybe you could post a sample between code tags?

The code that chooses the colours for freq bands is:

   analogWrite(ledPinR, spectrumValue[1]);
   analogWrite(ledPinG, spectrumValue[4]);
   analogWrite(ledPinB, spectrumValue[6]);

You can choose channel numbers 0 to 6 in the square brackets.

Perfect I have everything running normal, LED's are still on despite the serial monitor showing all 0's when the music is paused/off. Last question do you know a way I could safely power the Arduino through a car battery if I wanted it to stay inside my car?

balti:
LED's are still on despite the serial monitor showing all 0's when the music is paused/off.

I don't understand why that is happening. If you reset the Arduino while the music is paused, to the leds go out?

As to powering the circuit in the car, there are two problems. One is that while the engine is running, the voltage can be 14V or more. This may overload the leds or the Arduino. The second is that high voltage spikes can be present, which could also damage the circuit. I'm not an expert on how to protect from those problems, perhaps another forum member can advise.

I think it's the way it's wired to be honest. If it's plugged into the VIN and it has power going through it then I don't see anything in the code to stop it from giving it light.

balti:
I don't see anything in the code to stop it from giving it light.

I can. If you see zero values on the serial monitor, then zero values are also given to analogWrite, so the leds should be off. Now, what about my question?