# Current from I/O PIN

Each of the 54 digital pins on the Due can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 3.3 volts. Each pin can provide (source) a current of 3 mA or 15 mA...

So... If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

Yes, that is what a current limit means. If you want 20mA then use a transistor.

Grumpy_Mike:

If i want to use a LED that needs 20mA (i use to do it with arduino uno) there is risk (maybe is sure) to broke The board???

Yes, that is what a current limit means. If you want 20mA then use a transistor.

Is required a particular bjt for example??? Arduino Du gives 3mA... If i use a classic 2N222?

Another question... Which is The pin at 3mA, and which is at 15mA?

Here's a somewhat badly formatted and unverified list of the pins

``````Pin Port     Func
0   PA8          RX0
1   PA9          TX0                    15
2   PB25         Digital Pin 2
3   PC28         Digital Pin 3          15
4   PA29 and PC26   Digital Pin 4       15
5   PC25         Digital Pin 5          15
6   PC24         Digital Pin 6          15
7   PC23         Digital Pin 7          15
8   PC22         Digital Pin 8          15
9   PC21         Digital Pin 9          15
10   PA28 and PC29   Digital Pin 10      15
11   PD7          Digital Pin 11         15
12   PD8          Digital Pin 12         15
13   PB27   Digital Pin 13 / Amber LED "L"
14   PD4          TX3                   15
15   PD5          RX3                   15
16   PA13         TX2
17   PA12         RX2
18   PA11         TX1
19   PA10         RX1
20   PB12         SDA
21   PB13         SCL
22   PB26         Digital Pin 22
23   PA14         Digital Pin 23         15
24   PA15         Digital Pin 24         15
25   PD0          Digital Pin 25         15
26   PD1          Digital pin 26         15
27   PD2          Digital Pin 27         15
28   PD3          Digital Pin 28         15
29   PD6          Digital Pin 29         15
30   PD9          Digital Pin 30         15
31   PA7          Digital Pin 31         15
32   PD10         Digital Pin 32
33   PC1          Digital Pin 33         15
34   PC2          Digital Pin 34         15
35   PC3          Digital Pin 35         15
36   PC4          Digital Pin 36         15
37   PC5          Digital Pin 37         15
38   PC6          Digital Pin 38         15
39   PC7          Digital Pin 39         15
40   PC8          Digital Pin 40         15
41   PC9          Digital Pin 41         15
42   PA19         Digital Pin 42         15
43   PA20         Digital Pin 43
44   PC19         Digital Pin 44         15
45   PC18         Digital Pin 45         15
46   PC17         Digital Pin 46         15
47   PC16         Digital Pin 47         15
48   PC15         Digital Pin 48         15
49   PC14         Digital Pin 49         15
50   PC13         Digital Pin 50         15
51   PC12         Digital Pin 51         15
52   PB21         Digital Pin 52
53   PB14         Digital Pin 53         15
66   PB15         DAC0
67   PB16         DAC1
68   PA1          CANRX
69   PA0          CANTX                15
70   PA17         SDA1
71   PA18         SCL1                 15
72   PC30         LED "RX"
73   PA21         LED "TX"
74   PA25         (MISO)               15
75   PA26         (MOSI)               15
76   PA27         (SCLK)               15
77   PA28         (NPCS0)              15
78   PB23         (unconnected)        15
USB   PB11         ID                  15
USB   PB10         VBOF                15
``````

The "15" indicates a high-current pin.

HC pins can source 15mA and sink 9. LC pins can source 3mA and sink 6.

Rob

Graynomad: Here's a somewhat badly formatted and unverified list of the pins

``````Pin Port     Func
0   PA8          RX0
1   PA9          TX0                    15
2   PB25         Digital Pin 2
3   PC28         Digital Pin 3          15
4   PA29 and PC26   Digital Pin 4       15
5   PC25         Digital Pin 5          15
6   PC24         Digital Pin 6          15
7   PC23         Digital Pin 7          15
8   PC22         Digital Pin 8          15
9   PC21         Digital Pin 9          15
10   PA28 and PC29   Digital Pin 10      15
11   PD7          Digital Pin 11         15
12   PD8          Digital Pin 12         15
13   PB27   Digital Pin 13 / Amber LED "L"
14   PD4          TX3                   15
15   PD5          RX3                   15
16   PA13         TX2
17   PA12         RX2
18   PA11         TX1
19   PA10         RX1
20   PB12         SDA
21   PB13         SCL
22   PB26         Digital Pin 22
23   PA14         Digital Pin 23         15
24   PA15         Digital Pin 24         15
25   PD0          Digital Pin 25         15
26   PD1          Digital pin 26         15
27   PD2          Digital Pin 27         15
28   PD3          Digital Pin 28         15
29   PD6          Digital Pin 29         15
30   PD9          Digital Pin 30         15
31   PA7          Digital Pin 31         15
32   PD10         Digital Pin 32
33   PC1          Digital Pin 33         15
34   PC2          Digital Pin 34         15
35   PC3          Digital Pin 35         15
36   PC4          Digital Pin 36         15
37   PC5          Digital Pin 37         15
38   PC6          Digital Pin 38         15
39   PC7          Digital Pin 39         15
40   PC8          Digital Pin 40         15
41   PC9          Digital Pin 41         15
42   PA19         Digital Pin 42         15
43   PA20         Digital Pin 43
44   PC19         Digital Pin 44         15
45   PC18         Digital Pin 45         15
46   PC17         Digital Pin 46         15
47   PC16         Digital Pin 47         15
48   PC15         Digital Pin 48         15
49   PC14         Digital Pin 49         15
50   PC13         Digital Pin 50         15
51   PC12         Digital Pin 51         15
52   PB21         Digital Pin 52
53   PB14         Digital Pin 53         15
66   PB15         DAC0
67   PB16         DAC1
68   PA1          CANRX
69   PA0          CANTX                15
70   PA17         SDA1
71   PA18         SCL1                 15
72   PC30         LED "RX"
73   PA21         LED "TX"
74   PA25         (MISO)               15
75   PA26         (MOSI)               15
76   PA27         (SCLK)               15
77   PA28         (NPCS0)              15
78   PB23         (unconnected)        15
USB   PB11         ID                  15
USB   PB10         VBOF                15
``````

The "15" indicates a high-current pin.

HC pins can source 15mA and sink 9. LC pins can source 3mA and sink 6.

Rob

Thankyou :) di D you find it on The datasheet from atmel?

Yes. As I said though not verified, nobody else has checked it.

Rob

Graynomad: Yes. As I said though not verified, nobody else has checked it.

Rob

I think that we have to know this from Arruino.cc before we can completely use the board... If i Connect a led on a wrong pin( we don't know The wrong pin xD) i could damage the arm!

franceslup: Is required a particular bjt for example??? Arduino Du gives 3mA... If i use a classic 2N222?

For the pins that only output upto 3 mA I would use FETs (like MOSFETs) instead of BJTs. This is because FETs are always controlled by voltage level, rather than current level, on their gate. You could still use many BJTs, like the 2N2222, but you'd have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current (which you'll have to limit to below 3 mA).

but you'd have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current

So do we ensure this by rewriting physics?

A BJT is a current controlled device, you can't do anything to change that. A typical small signal BJT has a gain in the region of 200, so for 3mA you can switch up to 600mA.

Grumpy_Mike:

but you’d have to make sure the BJT is biased so it is controlled by its base-emitter voltage, and not the base-emitter current

So do we ensure this by rewriting physics?

Two words: “Voltage buffers”. In that type of circuit the current (while still necessary to operate the BJT) can be set arbitrarily to a fairly small level and VIN determines VOUT. Unless you think a NPN common collector circuit requires non-standard physics…

Edit: Perhaps I overstated things a little by using the words “have to” instead of "should, and Grumpy_Mike is certainly correct that 3 mA can control a current hundreds of times larger. However, it is entirely possible to use a BJT so that one voltage controls another without violating the known laws of physics!

However, it is entirely possible to use a BJT so that one voltage controls another without violating the known laws of physics!

Now from that link I suspect you are not suggesting using an op amp. The whole point of a BJT is that it is driven by current, not voltage. That current might be small but it is current never the less because it is current that makes the transistor work. FETs on the other hand are voltage devices and draw negligible current apart from the initial charging of the gate source capacitance. All three configurations of the transistor are called a voltage buffer on that page.

Lets look at each in turn:- 1) Common emitter - the normal way I would recommend, base current determines collector current

2) Common base - note the page says this is not suitable for a TTL voltage buffer, it has a low gain and typically I use this for video coupling.

3) Common collector better known as an emitter follower. - This has no voltage gain but a current gain, you do not need a base resistor because of the feedback on the emitter keeping the emitter / base voltage stable. However this is 0.7V so this means when you use it as a voltage buffer you loose 0.7V. Used with the Due that will reduce the voltage output from 3V3 to 2.6V. When lighting an LED this will not be high enough for blue and white LEDs although it is enough for red and green. Again I would not recommend this due to the voltage drop that it produces.

thank you guys... I tryied a configuration On pspice.. if i use an 2N222 NPN BJT in common emitter mode, with 10K resistor on base (on a pin of arduino 2 so 3.3v).... the current on the base is less then 1mA... i don't remember the value of the Vcc on the led... maybe was 5v... So i think i can use a BJT ;)

the current on the base is less then 1mA

In fact it is a lot less than 1mA it is 0.26mA. Remember at 3V3 the 0.7V base emitter drop is a lot more significant. So you use the voltage across the base resistor of 3.3 - 0.7 = 2.6V for your calculations. You can afford that base resistor to be down at 1K and still be within the limit. I would use 4K7 - (0.5mA) force of habit really.

Grumpy_Mike:
The whole point of a BJT is that it is driven by current, not voltage. That current might be small but it is current never the less because it is current that makes the transistor work. FETs on the other hand are voltage devices and draw negligible current apart from the initial charging of the gate source capacitance.

I never stated that a BJT could work without current! I originally recommended using FETs over on the 3 mA pins because I know the difference on how they operate.

Grumpy_Mike:
Lets look at each in turn:-

1. Common emitter - the normal way I would recommend, base current determines collector current

2. Common base - note the page says this is not suitable for a TTL voltage buffer, it has a low gain and typically I use this for video coupling.

3. Common collector better known as an emitter follower. - This has no voltage gain but a current gain, you do not need a base resistor because of the feedback on the emitter keeping the emitter / base voltage stable. However this is 0.7V so this means when you use it as a voltage buffer you loose 0.7V. Used with the Due that will reduce the voltage output from 3V3 to 2.6V. When lighting an LED this will not be high enough for blue and white LEDs although it is enough for red and green. Again I would not recommend this due to the voltage drop that it produces.

Although you are correct that I should have stated, “common emitter” and not “common collector”. I… wasn’t in a frame of mind conducive to self proof-reading when I wrote it. I took your comment in a way you probably didn’t mean, and furthermore let it irritate me more than I should have even if you did.

Regardless, with NPN a common emitter circuit the voltage difference between the base and emitter will be the VIN. Since VOUT can be expressed as follows VOUT = AV * VIN; how is VIN not effectively controlling VOUT? Yes, I intentionally didn’t mention that the current will be amplified as well and that is fundamental to the operation of the BJT. However, in my mind at least, it wasn’t necessary because the maximum current is so low and all the pins except DAC0 and DAC1 are either outputting digital or PWM signals. So it’s just easier when biasing the circuit to concentrate on the voltage, either setting it up to be an actual voltage amplifier or a switch, and only address the current in the context of ensuring it doesn’t go above 3 mA.

I solved the question
With a BJT NPN and some resistor…
The Vcc on the led is a 9V battery

Graynomad: Here's a somewhat badly formatted and unverified list of the pins

``````Pin Port     Func
0   PA8          RX0
1   PA9          TX0                    15
2   PB25         Digital Pin 2
3   PC28         Digital Pin 3          15
4   PA29 and PC26   Digital Pin 4       15
5   PC25         Digital Pin 5          15
6   PC24         Digital Pin 6          15
7   PC23         Digital Pin 7          15
8   PC22         Digital Pin 8          15
9   PC21         Digital Pin 9          15
10   PA28 and PC29   Digital Pin 10      15
11   PD7          Digital Pin 11         15
12   PD8          Digital Pin 12         15
13   PB27   Digital Pin 13 / Amber LED "L"
14   PD4          TX3                   15
15   PD5          RX3                   15
16   PA13         TX2
17   PA12         RX2
18   PA11         TX1
19   PA10         RX1
20   PB12         SDA
21   PB13         SCL
22   PB26         Digital Pin 22
23   PA14         Digital Pin 23         15
24   PA15         Digital Pin 24         15
25   PD0          Digital Pin 25         15
26   PD1          Digital pin 26         15
27   PD2          Digital Pin 27         15
28   PD3          Digital Pin 28         15
29   PD6          Digital Pin 29         15
30   PD9          Digital Pin 30         15
31   PA7          Digital Pin 31         15
32   PD10         Digital Pin 32
33   PC1          Digital Pin 33         15
34   PC2          Digital Pin 34         15
35   PC3          Digital Pin 35         15
36   PC4          Digital Pin 36         15
37   PC5          Digital Pin 37         15
38   PC6          Digital Pin 38         15
39   PC7          Digital Pin 39         15
40   PC8          Digital Pin 40         15
41   PC9          Digital Pin 41         15
42   PA19         Digital Pin 42         15
43   PA20         Digital Pin 43
44   PC19         Digital Pin 44         15
45   PC18         Digital Pin 45         15
46   PC17         Digital Pin 46         15
47   PC16         Digital Pin 47         15
48   PC15         Digital Pin 48         15
49   PC14         Digital Pin 49         15
50   PC13         Digital Pin 50         15
51   PC12         Digital Pin 51         15
52   PB21         Digital Pin 52
53   PB14         Digital Pin 53         15
66   PB15         DAC0
67   PB16         DAC1
68   PA1          CANRX
69   PA0          CANTX                15
70   PA17         SDA1
71   PA18         SCL1                 15
72   PC30         LED "RX"
73   PA21         LED "TX"
74   PA25         (MISO)               15
75   PA26         (MOSI)               15
76   PA27         (SCLK)               15
77   PA28         (NPCS0)              15
78   PB23         (unconnected)        15
USB   PB11         ID                  15
USB   PB10         VBOF                15
``````

The "15" indicates a high-current pin.

HC pins can source 15mA and sink 9. LC pins can source 3mA and sink 6.

Rob

I think pin 32 is HC and so is pin 72.

Other additions: timer pins: 2-5, 10-13, 58,60,61 PWM pins: 6-9

pin attributes are set in hardware/arduino/sam/variants/arduino_due_x/variant.cpp

analogWrite() in hardware/arduino/sam/cores/arduino/wiring_analog.c does analog out using either hardware DAC, PWM, or Timer/Counter pins else does high/low on digital pins.

Hi,
i hope I’m on topic.
Pls can anyone confirm my interface circuits for DUE?
There are mountains of examples for UNO but i didn’t find any for DUE and i don’t want to fry my 20 minutes old DUE.

Looks fine. I woudn't use that seriese resistor on the input, it is just a waste, but it does no harm.

Or you can look for LEDs that are sufficiently bright when used at 3mA...