Go Down

Topic: newbie want to use pot to dimm led (Read 143 times) previous topic - next topic

lamal

Hi all,

I am newbie on eleclronic. I want to use a pot to dim 3 LED. Could I do that as the following pic? I try it work but the pot just turn about 10 degree and those LED is off. how can i make the pot less sensitive? Thanks. 

5

PerryBebbington

Use a much lower value pot, maybe 470 Ohms or 1k.


larryd

Connect each LED (with resistor) to a 'PWM' pin on an Arduino UNO.

Make a 'voltage divider' out of a resistor and your potentiometer.

Feed this voltage divider to analog input A0.

Use the reading from A0 to adjust the duty cycle of the PWM pin.




No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

johnerrington

Hi Lamal - nice diagram!

As larryD says the output from the arduino pins should be controlling the LED brightness via Pulse Width Modulation (PWM. )

If you use a potential divider cvircuit to control the brightness you may find a log taper pot gives best results.

I'm trying to help. If I find your question interesting I'll give you karma. If you find my input useful please give me karma (I need it)

lamal

Connect each LED (with resistor) to a 'PWM' pin on an Arduino UNO.

Make a 'voltage divider' out of a resistor and your potentiometer.

Feed this voltage divider to analog input A0.

Use the reading from A0 to adjust the duty cycle of the PWM pin.





Thanks, I have tried this way and read few exmaple about the code, but not sucess. 

lamal

Hi Lamal - nice diagram!

As larryD says the output from the arduino pins should be controlling the LED brightness via Pulse Width Modulation (PWM. )

If you use a potential divider cvircuit to control the brightness you may find a log taper pot gives best results.


Thanks for the explaination! Apperciated

larryd

"  I have tried this way and read few exmaple about the code, but not sucess. "

Please show us what you tried.

Show us a good schematic of your circuit. Show us a good image of your 'actual' wiring.  Give links to components. Posting images:  https://forum.arduino.cc/index.php?topic=519037.0

Use CTRL T to format your code. Attach your 'complete' sketch between code tags [code]Paste your sketch here[/code]


No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

MarkT

Hi all,

I am newbie on eleclronic. I want to use a pot to dim 3 LED. Could I do that as the following pic? I try it work but the pot just turn about 10 degree and those LED is off. how can i make the pot less sensitive? Thanks.

5

This a circuit with two issues:
1) The pot should be reverse logarithmic taper for a good brightness curve. Such pots are hard
to find.  Perceived brightness of an LED is a logarithmic function of current, and only a rev. log.
pot can give a reasonably intuitive response.

2) When the pot value is high, the 100 ohm current-sharing resistors have very little voltage drop,
so they stop compensating for differences in the LED forward voltage, and they will fade at different
rates unless very well matched (for instance being from the same manufacturing batch)

If the LEDs can be in series you get current sharing for free (although this may require a higher
voltage supply)

Using PWM like the rest of the world is the way to go if there's a microcontroller around.  For good
brightness curve you use an exponential function in the code to map brightness to duty cycle.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

raschemmel

#9
Oct 19, 2020, 05:03 pm Last Edit: Oct 19, 2020, 05:04 pm by raschemmel
I think if you are going to post on the forum for advice, you should follow it.

As stated, the proper way to do this is
Connect leds to PWM pins.
use the pot as an analog input on an analog pin (connect one end to +5V,
connect the other end to GND, connect WIPER to A0.
Read the value with analogRead(), write the desired value with analogWrite().
End of story.

CrossRoads

Code: [Select]

void loop(){
potLevel = analogRead (A0) >> 4; // read pot, 0 to 1023, divide by 4, so 0 to 255
analogWrite (pwmPin, potLevel); // 3,5,6,9,10,11 are the PWM pin choices
}

Keep the current limit resistors. The output to the LED is a 0/5V pulse of varying width, how wide the pulse determines how bright your eye sees the color.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up