Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Led Fading Steps

Status
Not open for further replies.

Suraj143

Active Member
Hi I need to fade an LED using 256 steps. My LED is connected via a 220R resister to the PIC.

When I give 2V, 20mA to the LED its lighting up very bright.

My problem is what do I have to write to duty cycle register?

Do I need to calculate the duty cycle register for 2V or for 5V?
 
You just vary the duty from 0 to 100%. The output from the pic will be 5V of which 3V will be dropped by the resistor and the other 2V by the LED. The current through the LED will be (V/R) 3/220 amps = 13.5mA.
 
You just vary the duty from 0 to 100%. The output from the pic will be 5V of which 3V will be dropped by the resistor and the other 2V by the LED. The current through the LED will be (V/R) 3/220 amps = 13.5mA.

Hi thanks.

220R will supply only 13.5mA that is quite not enough for the LED to light up fully bright.

150R will give me the best brightness (20mA).

After replacing 150R I'll change the duty cycle register.

That means duty cycle will vary this current from 0mA to 20mA.
 
The reason I asked because

The led will light from 1.75V.That means (255/5) X 1.75 = 89

If I write the duty cycle register below 89 there will be no effect,LED will off 0-1.75V.

In this case the duty cycle zero will starts from 89?

This is what I want to verify :)
 
Last edited:
No, the duty cycle will start from 1. The PWM is not converted to DC (I hope) but instead flashes the LED at full brightness. It the duty cycle is 10% then the LED will be at full brightness for 10% of the time and so you see it as dull.

Mike.
 
No, the duty cycle will start from 1. The PWM is not converted to DC (I hope) but instead flashes the LED at full brightness. It the duty cycle is 10% then the LED will be at full brightness for 10% of the time and so you see it as dull.

Mike.

Thanks for verifying.That means what ever the value is write to the duty cycle register it will turn on the LED with full brightness for the specific time written to the register.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top