Green LEDs not turning on, red LEDs are

I am making a simple project where I tap on a piezo and the harder I hit it the more LEDs turn on. I have decided to make the lower hits use green LEDs and the higher hits use red LEDs. What I initially noticed was that the green LEDs would not turn on, then the red LEDs will turn on later. This then made me switch the green LEDs out with the red LEDs to try to find the source of the problem, and voila, the red LEDs work in the slot and the green LEDs don't. The green LEDs definitely do work as I have just tested them with a simple circuit on the breadboard.

I hope I have said this clearly. And bare in mind, I'm still only a beginner :wink:

Thanks

Hi, welcome to the forum.
We need to know (a lot) more.
Which Arduino board do you have ?
Can you make a photo of it ?
Please show us your sketch.
Do you use resistors ?

Green leds need a higher voltage than red leds. When you would have green leds parallel with red leds, only the red leds turn on. I don't know if that is the problem, you can solve it by using a seperate resistor for every led.

Don't suppose you happen to be using a 3V battery, do you?

Red LEDs have forward voltages in the range 1.5 to 1.9V or so, green are typically 3.0V - which makes me wonder if you have connected them in parallel without current limiting
resistors...

Or put another way we need to see what you've wired up - a diagram, as well as your sketch
in full in code tags as explained in the sticky threads.

Oops, excuse my ignorance. Well anyways, after a bit on insight from you guys I decided to go ahead and measure the current flowing through the LED, and together with the forward voltages you guys supplied for the different coloured LEDs I figured that I need to get my hands on some smaller resistor values (330ohm?) as opposed to the 470ohm resistors I was using beforehand.

Thanks

I figured that I need to get my hands on some smaller resistor values (330ohm?) as opposed to the 470ohm resistors I was using beforehand.

Like Peter said, each LED needs it's own resistor.

A slightly different resistor value is just going to make the LED dimmer or brighter.

cricket0140:
I figured that I need to get my hands on some smaller resistor values (330ohm?) as opposed to the 470ohm resistors I was using beforehand.

Umm. No!

What you need to do is to answer the questions that have been asked.

Peter_n:
Which Arduino board do you have ?
Can you make a photo of it ?
Please show us your sketch.
Do you use resistors ?

Okay guys sorry again. I have a Freetronics Eleven (Arduino Uno compatible(apparently)). Here's a picture of everthing in it's place.

Here is the sketch

int knock = 0;
int lightdelay = 100;
int minknockLimit = 1;
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;

void setup()
{
Serial.begin(38400);
}

void loop()
{
knock = analogRead(0);
if(knock>minknockLimit)
{
Serial.println(knock);
}
if(knock>5)
{
digitalWrite(led1, HIGH);
delay(lightdelay);
digitalWrite(led1, LOW);
}
if(knock>20)
{
digitalWrite(led2, HIGH);
delay(lightdelay);
digitalWrite(led2, LOW);
}
if(knock>50)
{
digitalWrite(led3, HIGH);
delay(lightdelay);
digitalWrite(led3, LOW);
}
if(knock>70)
{
digitalWrite(led4, HIGH);
delay(lightdelay);
digitalWrite(led4, LOW);
}
if(knock>90)
{
digitalWrite(led5, HIGH);
delay(lightdelay);
digitalWrite(led5, LOW);
}
if(knock>100)
{
digitalWrite(led6, HIGH);
delay(lightdelay);
digitalWrite(led6, LOW);
}
if(knock>200)
{
digitalWrite(led7, HIGH);
delay(lightdelay);
digitalWrite(led7, LOW);
}
if(knock>400)
{
digitalWrite(led8, HIGH);
delay(lightdelay);
digitalWrite(led8, LOW);
}
}

These two things are probably going to be the most disgusting things you will see today, this week, even for your life. I'm just not totally to grips with arrays etc, but that's for another day. And yeah I do have individual resistors for each LED, which are currently 470ohm each. I also power the board through the USB port connected to the computer.

Thanks guys

When posting code use the icon next to the quote, not the quote.

You have not set any of the LED pins to be outputs. You should do this in the setup function for any pin you want to drive an LED with.

This is why the green LEDs did not work, the output voltage was not good enough. Without setting the pins to be outputs what you are doing by writing to them is simply turning on and off the 35K internal pull up resistor, which is just enough to light a red one but not a green.

Well I now feel stupid. But I'm learning I guess.

Thanks guys for the help and baring with me, I appreciate it.