# Arduino Mega Digital I/O voltage?

Good afternoon,

I have got my 128x64 LCD working and I'm loving it! took a long while to get my head around all the various diagrams and which one I needed but got there in the end :)

Now I'm onto the IR project and I'm struggling... wonder if you can help...

I have a 5mm high power IR LED with a VF of 1.7

http://arcfn.com/images/ir-schematic.png

I'm reading the spec sheets and it says the LED goes to PWM output 3. I'm also reading these have a voltage of 0 - 5 v?

So how am I meant to work out what resistor is required here when I do not know the voltage?

If I base it on 3.3?

3.3v - 1.7 VF / 0.500mA = 3.2k ohms?

5v - 1.7 VF / .500mA = 6.6k ohms?

but which power supply will this digital i/o pin use?

I'm sure there is something simple I'm overlooking and hope you can point it out to me!

Thanks for any time you can spare...

8)

The voltage on a Mega pin is 5v when high, 0v when low, simple.

Where does the .5mA come from? The schematic shows a 100R resistor, so that's 33mA through the LED.

Rob

For a "high-power" LED you should consider driving it through a transistor instead of directly from an I/O pin, which is limited to 40mA absolute maximum (and in practicality I would advise limiting to 50% of that long-term, so 20mA).

A sample schematic for how to do so is shown on page 3 (top left) of our Gadget Shield schematic.

-- The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

Thank you very much Rob, RuggedCircuits & Graynomad,

The .5ma comes from the LED itself....so I’m clearly making a mistake here! Which also helps me see there is an error in my understanding...

So with this 1.7VF LED at .5ma, and the 5v pin from Arduino (thanks for clearing this up) - can you please tell me which resistor I will need and more importantly, walk me through the calculation so I don’t make the same mistake again..? (and hopefully save asking you guys again ? )

OK, let's go through the calculation then explain why it is wrong :)

The Arduino supplies 5V at its output pin (more or less...it's not exact) when it is HIGH. The LED will drop 1.7V of this voltage, leaving 3.3V for the resistor to drop. If you want 0.5mA to flow through the LED, then 0.5mA also flows through the resistor and we apply Ohm's Law:

R = V / I = 3.3V / 0.5mA = 6600 ohms.

This is wrong because 0.5mA is much too little current to light a "high-power LED"!! Do you have a part number for this LED that you plan to use? Perhaps that will guide you as to how much current you really need.

-- The Rugged Circuits Yellowjacket: 802.11 WiFi module with ATmega328P microcontroller, only 1.6" x 1.2", bootloader

Absolute hero! nice one 8)

http://www.maplin.co.uk/high-power-infrared-emittingdiode-2253

This is the LED... there was one that came with the kit that must be 4mm but was unidentified so not intersted in using it... also my front room is pretty big so want the highest power possible... if it will work OK?

Excellent...you can see from the specifications that this LED is rated for 100mA to give you the 1.7V of voltage drop. I am guessing that 100mA is a "pulse" rating and you don't want to drive it continuously at 100mA, but that's OK as that's how IR transmission works anyways, in pulses.

You definitely are not going to want to drive 100mA directly from an Arduino pin. Use the circuit I suggested. 100mA of current pulses should give you a nice long range on your IR transmission (several metres).

-- Beat707: MIDI drum machine / sequencer / groove-box for Arduino

Spot on thanks for explaining so well!

That circuit looks well beyond anything I can understand now so going to have to take it apart bit until that makes sense too... looks ace though... will have another look in a moment.

Is there a way to make this all work using Ken's instructions?

http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

This protoshield looks infinitely easier than the circuit so if I can get away with the easy/lazy approach for now.. would I just need a smaller LED and a smaller resistor?

I have this as well

http://www.maplin.co.uk/miniature-infrared-source-2251 wont get the same range but might save using all the transistors

this has VF of 1.6

so 3.4v / 60 ma VC = 5.666666667 ohms..

is this right?

ken's pic has a resistor of brown black brown? so 100r? getting more lost now I think...

massive thanks for all your time...

Trying to make sense of the circuit... T12 & 13 etc are transistors... but what kind? LED 6 - is that the part number underneath it? C1 - Capacitor...10uf type... R22 & R23...one says 100 and the other "DNP"... not sure what this is? is there anywhere that explains what this all means? want to learn but can't keep meeting like this you'll never get away from your PC! XD

Is there a way to make this all work using Ken's instructions?

Sure, Ken's library is the software. It doesn't mind whether the hardware is hanging directly off the pin or amplified with a transistor.

This protoshield looks infinitely easier than the circuit so if I can get away with the easy/lazy approach for now.. would I just need a smaller LED and a smaller resistor?

The easy/lazy approach is to limit the current to 20mA and do away with the transistor. Then you just connect up the LED and resistor directly to the Arduino pin. Assuming Vf is 1.5V or so I'd use a resistor of (5-1.5)/0.02 = 175 ohms or so (180 ohms is a standard value).

T12 & 13 etc are transistors... but what kind?

T12 and T13 are just testpoints :) You can ignore them. They are on the Gadget Shield so that students can use it as a learning tool to see how transistors/LED's/etc. operate.

LED 6 - is that the part number underneath it?

Indeed it is.

R22 & R23...one says 100 and the other "DNP"... not sure what this is?

DNP means "do not place" -- the part is not on the board by default. It allows people who want to crank up the current a little bit to put another resistor in parallel without having to desolder the existing 100 ohm resistor. You can ignore it as you'll just be swapping resistors in and out.

is there anywhere that explains what this all means?

Beginner's books on electronics! I don't have any specific recommendations but I know this question comes up in the forums regularly so a bit of hunting around might lead you to some recommendations.

-- The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins

Thanks for all your patience.. I do a lot of work on the Ubuntu forum so will make sure I spend time here helping other newbies when I know it all. Or at least enough to get by.... :)

...Finally it is all starting to make sense.... but now I'll be up all night tinkering again!

I have ordered the getting started with arduino book... am sure that will clear it up when it finally arrives...

last question! the LED says : the forward voltage is 1.6v @40mA (another part of the page says 60mA)

• so will the LED be able to function at 20mA...maybe go for 30 which is closer to the arduino limit but closer to what the LED wants? or does Ken's software do something clever here?

can feel the penny dropping...

:stuck_out_tongue_closed_eyes:

Sure, the LED can function at 20mA...it can function at 0.000002mA, it's just a question of how bright it's going to be!

Ken's software is entirely independent of the current at which you run your LED. The higher the current, the brighter the LED, the longer the range of the LED. But Ken's software has nothing to do with the range.

-- BeatVox: inexpensive sound shield for Arduino, 3.5mm stereo output, 512Kbyte FLASH

Graynomad: The voltage on a Mega pin is 5v when high, 0v when low, simple.

Rob

I'm new to this. Is this always true? Even when you have an external 9v power supply instead of USB power? And if so, is there any way to get the digital pin to output the full 9v from my power supply, or should I be doing something else?

telarium:

Graynomad: The voltage on a Mega pin is 5v when high, 0v when low, simple.

Rob

I'm new to this. Is this always true? Even when you have an external 9v power supply instead of USB power? And if so, is there any way to get the digital pin to output the full 9v from my power supply, or should I be doing something else?

Always true. The arduino output pins will always reflect the voltage level the processor chip is powered with. On a standard Arduino board the chips are powered by either the USB +5vdc power, or the on-board +5vdc voltage regulator. Your +9vdc voltage source connected to the arduino's external power connector feeds the input to the on-board voltage regulator, not directly to the board's chips. The chips on the board can not work at higher then +5vdc, they would be destroyed.

If you need high voltage logic levels you must use an external switching transistor that the arduino can turn on and off the transistor with +5vdc, but the transistor's collector load can be wired to any desired DC voltage level. That's how an arduino can be made to power 12 volt motors, lamps, solenoids, and other devices requiring higher then +5vdc or more then 20ma of current draw.

Lefty

Thanks again! I was thinking about it last night and figured this has to be the case but always best to be sure :)

I'll start off using 20mA as per your reccomendation and only go to 30 if I need the range...

For this exernal switching transistor is there a specific one I should use?

have learnt a fair amount over the past week and loads more over the past day - stuff that is actually correct - so can't thank you enough...

For this exernal switching transistor is there a specific one I should use?

Not too critical, the transistor used has to have maximum voltage and current ratings well above (2X-5X) the actual voltage and current levels you will be switching. It's best to follow a proven schematic and there are plenty of examples around the arduino playground showing use of transistors as switches.

Lefty

Thank you, have had the LCD working for a while now and wiring up a keypad at the moment... its small steps but at least it's progress!

will look at more examples and try to make it all work now... have enough to keep myself busy so nice one again 8)