Continue to Site

# 8 Leds on portb, PIC16F84A

Status
Not open for further replies.

#### zanor

##### Member level 4
As a start I want to connect 8 led's(3V, 20mA) to portb.
But from what I read in the datasheet, maximun current out from portb is 100mA.

So how do I do this?

And since output voltage is ~5V (right?) and the led is 3V, 20mA.

Will a 100Ohm resistance work for voltage drop before the led?

BTW: How do I post real links on this forum?

#### sp

##### Full Member level 6
the 3V is the voltage drop across the LED.... 20mA is the max current allowed...

so the R = (5-3)/20m

the max current on portb wont burn ur LED... it depend on load..

sp

#### Buriedcode

##### Full Member level 6
Hello,

But from what I read in the datasheet, maximun current out from portb is 100mA.

So how do I do this?

This is indeed correct. The problem isn't that you'll burn out your LED's, its that you 'may' burn out portB on your PIC. I have done this in the past with the 16F84A.

What you would need to do is choose a resistor value that means, each LED will only draw 1/8th of the maximum current allowed through portB. In this case...100/8mA

Assuming you're powering your PIC with 5v, that means that the voltage across the resisotr should be about 2v. (double check the V-drop across the LED though, in a test circuit, resistor -> LED).

So, using the ever-useful V=IR. We want to know R. Because portb is rated at 100mA, the maximum current for each LED (assuming you want them all the same brightness) is 100/8 = 12.5mA = 0.0125A. We now have 'I' and V'.

V=IR. Therefore... R=V/I = 2/0.0125 = 160 ohms. One resistor for each LED.

This relies on the fact that your LED voltage drop is about 3v.

If you want each LED to have 20mA. Then you will need to drive each LED with a transistor...you can get driver chips from most distributors.

regards,

BuriedCode.

Points: 2