# HP Forums

Full Version: Calculate RL resistor for LEDs diodes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I leave the link to a small program I wrote to calculate the current limiting resistor for a given number of LED diodes in series.

http://www.ucontrol.com.ar/forosmf/tutor.../#msg82727

It's in Spanish, but if you think you need someone can translate it to English language.
I hope you find it useful.

Code:

﻿EXPORT resistencia_led()
BEGIN

//Declaro variables:
local RL, VLED, NLED, ILED,VCC,POT;
local lista1, lista2;

lista1 := {"Vcc:", "VLED:", "ILED:","nLED:"};
lista2 := {"Tensión de la fuente (V)","Tensión del LED (V)","Corriente del LED (A)","Número de LEDs conectados en serie"};

INPUT ({VCC,VLED, ILED,NLED},"Cálculo resistencia limitadora (Ohms)",lista1, lista2);

RL := (VCC-VLED*NLED)/ILED;

IF RL<0 THEN
MSGBOX("El número de LEDs excede la tensión de la fuente.");
ELSE
POT := (ILED^2)*RL;
RL := ROUND(RL,0);
POT := ROUND(POT,1);
print (RL);
print (POT);
MSGBOX("La resistencia limitadora debe ser de "+ RL +" Ohm(s) y al menos " + POT+ " Watt(s).");
END;

END;

Greetings.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :