Post Page Advertisement [Top]

Choosing The Resistor To Use With LEDs

Choosing The Resistor To Use With LEDs

This question gets asked every day in Answers and the Forums: What resistor do I use with my LEDs? So I've put together several different ways to figure it out.

Lets get right to it:
Each of the steps do the same thing. Step 1 is the simplest and we go downhill from there. 

No mater what way you choose you must first know these three things:

Supply voltage This is how much power you're putting into the circuit. Batteries and wall warts will have the output voltage printed on them somewhere. If you're using multiple batteries*, add the voltage together.LED Voltage Sometimes "Forward Voltage" but usually just abbreviated "V".LED Current Sometimes "Forward Current". This is listed in milliamps or "mA".
Both of these last two can be found on the packaging for your LEDs or on your supplier's web site. If they list a range ("20-30mA") pick a value in the middle (25 in this case). Here are some typical values, but use your own values to be sure you don't burn out your LEDs!:

Red LED: 2V 15mA
Green LED: 2.1V 20mA
Blue LED: 3.2V 25mA
While LED: 3.2V 25mA

Okay, lets get started!

* Batteries in series

Introduction photo credits:
LED photo by Luisanto.
Resistor photo by oskay.

STEP 1: THE WEB WAY

The easiest way is to use one of the online calculators provided below.

Just click on one and enter the info from the previous step and you're set! You only need to go to one.

The LED Center (For single LEDs)

The LED Center (For arrays of LEDs)

LED Calculator.net (For single or arrays of LEDs)

LED Calculator.com (For single or arrays of LEDs)

STEP 2: THE RETRO WAY

Go to Evil Mad Scientist Labs web page at this linkand print and make your own slide rule-like calculator.

PDF, assembly and usage instructions are all on the page linked above.

It's pretty nifty and ends up being about business card size so you can keep one in that box with the rest of your LEDs.

STEP 3: THE HARD WAY (MATH!)

All the calculators in step 2 are just doing some simple math that you can do at home:

The formula to calculate resistance in a circuit is:R=V/I or, more relevant to what we're doing:

(Source Volts - LED Volts) / (Current / 1000) = Resistance*

So if we have a 12v battery powering a 3.5V 25mA LED our formula becomes:

(12 - 3.5) / (25 / 1000) = 340ohms.

But wait! (you might say) When I use one of the other calculators I get 390 ohms! And indeed you do. That's because its hard to buy a 340 ohm resistor and easy to buy a 390 ohm one. Just use the nearest one you can easily find.

To learn more about this magic formula read aboutOhms Law.

* We're dividing the current by 1000 because our listing in in miliaps, or 1/1000th of an amp.

3 comments:

  1. http://www.electroschematics.com/11301/arduino-rfid-reader-rc522-access-control-system/

    ReplyDelete
  2. http://www.electroschematics.com/9824/arduino-rfid-access-control-em-18/

    ReplyDelete
  3. /* Arduino Simple RFID Access Control
    Using EM-18 RFID Reader Module
    Prefatory Code For Novices
    An inspired design. Thanks to Internet!
    T.K.Hareendran
    Project designed & tested at TechNode on 17.02.2014
    http://www.electroschematics.com */
    #define RELAYPIN 13
    #define WARNLEDPIN 12
    char tag[] ="51005F46642C"; // Replace with your own Tag ID
    char input[12]; // A variable to store the Tag ID being presented
    int count = 0; // A counter variable to navigate through the input[] character array
    boolean flag = 0; // A variable to store the Tag match status
    void setup()
    {
    Serial.begin(9600); // Initialise Serial Communication with the Serial Monitor
    pinMode(RELAYPIN,OUTPUT); // RELAY OUTPUT
    pinMode(WARNLEDPIN,OUTPUT); //WRONG TAG INDICATOR
    }
    void loop()
    {
    if(Serial.available())// Check if there is incoming data in the RFID Reader Serial Buffer.
    {
    count = 0; // Reset the counter to zero
    /* Keep reading Byte by Byte from the Buffer till the RFID Reader Buffer is empty
    or till 12 Bytes (the ID size of our Tag) is read */
    while(Serial.available() && count < 12)
    {
    input[count] = Serial.read(); // Read 1 Byte of data and store it in the input[] variable
    count++; // increment counter
    delay(5);
    }
    /* When the counter reaches 12 (the size of the ID) we stop and compare each value
    of the input[] to the corresponding stored value */
    if(count == 12) //
    {
    count =0; // reset counter varibale to 0
    flag = 1;
    /* Iterate through each value and compare till either the 12 values are
    all matching or till the first mistmatch occurs */
    while(count<12 && flag !=0)
    {
    if(input[count]==tag[count])
    flag = 1; // everytime the values match, we set the flag variable to 1
    else
    flag= 0;
    /* if the ID values don't match, set flag variable to 0 and
    stop comparing by exiting the while loop */
    count++; // increment i
    }
    }
    if(flag == 1) // If flag variable is 1, then it means the tags match
    {
    Serial.println("Access Allowed!");
    digitalWrite(RELAYPIN,HIGH);
    delay (5000);
    digitalWrite (RELAYPIN,LOW);
    }
    else
    {
    Serial.println("Access Denied"); // Incorrect Tag Message
    digitalWrite(WARNLEDPIN,HIGH);
    delay(5000);
    digitalWrite(WARNLEDPIN,LOW);
    }
    /* Fill the input variable array with a fixed value 'F' to overwrite
    all values getting it empty for the next read cycle */
    for(count=0; count<12; count++)
    {
    input[count]= 'F';
    }
    count = 0; // Reset counter variable
    }
    }

    ReplyDelete

Bottom Ad [Post Page]