led keeps burning

I have a led, and it just keeps burning, even where it's not supposed too.

This is my first schematic i ever drawn so it can have some mistakes in it (like missing a arduino..., anyway all PINs are my arduino pins afcorse).
I also added a photo, in case it makes more sense.

#define REL 0
#define POT A5
#define LDR A4
#define LED 1

long reportTime = 1000;

void setup() {
  pinMode(REL, OUTPUT);
  pinMode(POT, INPUT);
  pinMode(LDR, INPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600);

}

void loop(){
  int LDRval = analogRead(LDR);
  int POTval = analogRead(POT);

  if(millis() > reportTime) {
    Serial.println("LDRval ");
    Serial.println(LDRval);
    Serial.println("POTval ");
    Serial.println(POTval);
    Serial.println();
    
    reportTime = millis() + 1000;
  }

  if(LDRval > POTval) {
    digitalWrite(REL, HIGH);
    digitalWrite(LED, HIGH);
    delay(40); 
  } 
  else {
    digitalWrite(REL, LOW);
    digitalWrite(LED, LOW);
  }

}

I think the LDR is set up wrong. The way that works for me is:

+5V-----[resistor]------ --------[LDR]--------Gnd
|
|
|
|
Arduino pin

This forms a voltage divider; the voltage on the arduino pin is therefore dependant on both the fixed resistor resistance and the LDR resistance/

Onions.

It's the method from the book "getting started with arduino" .
I tried your setup aswell for the LDR but it made no difference.

Also the values that come with the serial.println are correct so both the pot and ldr are working.

s the method from the book "getting started with arduino"

So it is either a miss print or a missunderstanding on your part but this will eventually burn your LDR out so if you see it makes no diffrent then change it anyway.

If you have 10K in line with your LED you would not see it so the resistor is not the value you think it is. If it were 10R that would explain why you burn them out and also damage your arduino output pin.

look at the colors of the photo, it is 10k.
How fast can a arduino be damaged?

The arduino can be damaged in micro seconds.
Check that resistor with a meter, check the voltages with a meter. Don't use pin 1 because it interfere with the serial port.
If you can see the LED glow then you haven't got a 10k in line with it no matter what the colours say.

Grumpy_Mike:
The arduino can be damaged in micro seconds.
Check that resistor with a meter, check the voltages with a meter. Don't use pin 1 because it interfere with the serial port.
If you can see the LED glow then you haven't got a 10k in line with it no matter what the colours say.

Well my LEDs show up perfectly well with a 10k series resistor - depends if its a high-efficiency LED or not 8)

But agreed if the LED is burning out it can't be 10k

clankill3r:
look at the colors of the photo, it is 10k.
How fast can a arduino be damaged?

Sure it reads 10K.

In your program, you used pin 0 and 1 for REL and LED. But do you know that your serial port is using these two pins as well? You should use other pins and leave the serial port alone.

But do you know that your serial port is using these two pins as well?

Well I did say in reply #5. However even with this you can't burn out an LED with 10K in line with it.

It could be that:-

  1. The LED was faulty, but as thee are several that burned out so maybe a faulty batch.
  2. Faulty breadboard resulting in the resistor shorting out, but then I would expect the arduino to burn out before the LED.
  3. Connection on the board to Vin in place of +5v, but again with 10K you need 200V to get 20mA through an LED with 10K in line.
  4. Resistor not being 10K, either faulty or miss marked. I remember you used to be able to get resistors with the wrong colour bands on them. They were used for putting faults onto TVs for TV maintenance practical exams.
  5. Some accident when working with the circuit, like wiring it up when powered or brushing a power line in the wrong place.

clankill3r, sorry to ask a silly question but when you say your LED is burning do you mean you are damaging LEDs or just that the LED is on all the time?

If you mean its on all the time, and if you avoid using pins 0 and 1 as already suggested, what does the illumination look like is it constant or flickering and is it bright or dim.

Your LED will not turn off unless LDRval<=POTval.
Why not stick a print statement right next to where you set the LED pin LOW to see if your program ever gets there?
If it does put one next to where the LED is set HIGH as well to see if you are constantly toggling on/off.

You could also change the code just to just blink the LED on and off to help pin down where the problem is.

Does your book really say to use a 10k ohm resistor?
I have just started playing with my Arduino and the exercises, using several different LED types, have resistors between 270 and 560ohm. resistors.

I mean it's on, it was a bad word to choose from me, didn't think of that as being not a native english speaker.
The book often doesn't say what resistor to use so i play it safe.

It didnt glow that bright, just a litle btw.
I checked 2 times again and the resistor is really 10k, even with the multimeter.

Anyway......tadada i (you guys) fixed the problem!

I think it was the ports i used, i changed from 0 and 1 to 4 and 7.
Can the fact that i used serial.println have anything to do with it (by voltage the output where the led was)?

once more thanks!

Glad you got it fixed.

You had print statements in your code so you were sending data out on the serial pins.
The data goes out as lots of bits, so those bits would have been turning your LED on/off quickly if it was attached to the pins, this would light up the LED. You might have been able to see the LED flicker with the bits and it would probably be dim because, as with PWM, the signal to the LED was not on all the time.

I know your resistor is 10k ohms and that you have measured it but is that really what your book says to use?
If your circuit is working now so I guess 10k ohm is correct but it is twenty times bigger than what I have been told to use in my test circuits so it does seem very high.

Don't go using a small resistor just because of what I am saying or you may really start burning LEDs but if your LED is dim the resistance may be too high.

The book often lacks of info of what resistor to use so i use a 10k.
I know it's to high but for simple testing it's fine for me, better to high then to low right.

Better safe than sorry.
Would your first language be French?

dutch :slight_smile:

Nothing to do with this but those ultra bright leds are pretty cool, I've had them light up with just one side to ground or vcc and my hand on the other end, just the mains interference thru my body is enough to light it up, mind you skin has a resistance of 100k to 2 M

clankill3r:
dutch :slight_smile:

LOL lost in translation. Glad someone eventually realized you may mean something when using "burning". FYI, in Chinese, the turned on could be translated into driving like driving a car if someone is not careful. :grin:

First post here (been lurking) . Didn't see a kickback diode for the relay in the schematic. Hard to see from photo if there is one.