Pages: [1] 2   Go Down
Author Topic: led keeps burning  (Read 1566 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.





Code:
#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);
  }

}

Logged

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) smiley-grin

0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33982
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33982
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Online Online
Shannon Member
****
Karma: 206
Posts: 12071
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cool

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

[ I won't respond to messages, use the forum please ]

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7189
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33982
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Full Member
***
Karma: 1
Posts: 124
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dutch smiley
Logged

Pages: [1] 2   Go Up
Jump to: