Pages: [1]   Go Down
Author Topic: Different Brightness between 2 LEDs  (Read 410 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 139
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an ATtiny85 that is connected to a 10K pot and has 2 LEDs. One LED is HIGH all of the time and the other fades in and out depending on the position of the potentiometer. The odd thing is that when the potentiometer mapping to the PWM LED is completely on (255) it is about 50% as bright as the LED that is always on. They have the exact same resistor and when I switch the LEDs the same effect happens so it is not an issue with the LEDs. Additionally I have tried it with the internal 8mhz clock and an external 16mhz clock with the same effect. Any thoughts?

Here is my code
Code:
void setup(){
 // Serial.begin(9600);
  pinMode(1,OUTPUT); // led is always on
}

void loop(){
  int sensor_value = analogRead(A1);
  int output = map(sensor_value,0,1023,0,255);
  analogWrite(0,output); // this led is never as bright
  digitalWrite(1,HIGH);
//  Serial.println(output);
}
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 121
Posts: 4598
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you get if you do "analogWrite(0,255)"?
Logged

No, I don't answer questions sent in private messages...

Offline Offline
Full Member
***
Karma: 0
Posts: 139
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
analogWrite(0,255);
Produced 2 LEDs of the same brightness. That way worked! I double checked all the connections in the breadboard and switched out the LEDs, but the problem still persists with the potentiometer.

There is no logical explanation for this is there?

I checked that the potentiometer was correctly working by sending out the values to the Serial monitor via Arduino Uno
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 36
Posts: 1304
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a multimeter ?
You  could test voltage at the LED.
You exchanged the LEDs so you ruled out differences in the LEDs themselves.
Did you also change ports in the sketch ?
So do the dim function om pin 1 and the ON function on pin 0 ?

I wouldn't use a variable called output (even if it's lowercase), so try what happens if you give it a name that doesn't double a function or any other word used in IDE.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There is no logical explanation for this is there?
Well we don't believe in the supernatural around here so there is a logical explanation.

The first thing to do is to swap the diodes over and have everything else the same. Do you still see a difference?

Next look at the voltage waveform across each diode, does that show you anything.
Logged

Pages: [1]   Go Up
Jump to: