Wolfram Research

Function Repository Resource:

ResistorColorCode

Source Notebook

Generate an illustration of resistor color codes from a specified resistance

Contributed by: Jeff Bryant

ResourceFunction["ResistorColorCode"][resistance,"ColorList"]

generates a list of resistor color codes used to represent the specified resistance.

ResourceFunction["ResistorColorCode"][resistance,"Graphics"]

generates a resistor color code illustration used to represent the specified resistance found in analog electronics.

ResourceFunction["ResistorColorCode"][<|"Resistance"resistance,"Tolerance"tolerance|>,prop]

uses the specified resistance and tolerance.

Details and Options

Depending on the value provided, ResourceFunction["ResistorColorCode"] may return a pair of illustrations when there are equivalent representations.
ResourceFunction["ResistorColorCode"] takes the same options as Graphics.
Values for tolerance must be one of: 0.05%, .1%, .25%, .5%, 1%, 2%, 5%, 10%.
Since FromResistorColorCode returns a resistance and/or tolerance, this can result in alternate forms for the diagram that do not necessarily match the provided color list. A specified color list may result in a unique resistance and/or tolerance, but this can be represented graphically in multiple ways.

Examples

Basic Examples

Generate a list of colors corresponding to a resistor color code for a given resistance:

In[1]:=
ResourceFunction["ResistorColorCode"][
 Quantity[1.34, "Ohms"], "ColorList"]
Out[1]=

Display a graphical representation of the resistor:

In[2]:=
ResourceFunction["ResistorColorCode"][
 Quantity[1.34, "Ohms"], "Graphics"]
Out[2]=

Generate a pair of images when there are two equivalent color code representations:

In[3]:=
ResourceFunction["ResistorColorCode"][
 Quantity[5000, "Ohms"], "Graphics"]
Out[3]=

Generate a pair of color lists instead of graphics:

In[4]:=
ResourceFunction["ResistorColorCode"][
 Quantity[5000, "Ohms"], "ColorList"]
Out[4]=

The final stripe represents the tolerance value:

In[5]:=
ResourceFunction[
 "ResistorColorCode"][<|"Resistance" -> Quantity[5000, "Ohms"], "Tolerance" -> Quantity[1, "Percent"]|>, "Graphics"]
Out[5]=
In[6]:=
ResourceFunction[
 "ResistorColorCode"][<|"Resistance" -> Quantity[11600, "Ohms"], "Tolerance" -> Quantity[10, "Percent"]|>]
Out[6]=

Generate color lists including an entry for the tolerance:

In[7]:=
ResourceFunction[
 "ResistorColorCode"][<|"Resistance" -> Quantity[5000, "Ohms"], "Tolerance" -> Quantity[1, "Percent"]|>, "ColorList"]
Out[7]=

Options

When "Graphics" is specified, ResistorColorCode accepts the same options as Graphics:

In[8]:=
ResourceFunction["ResistorColorCode"][
 Quantity[1.34, "Ohms"], "Graphics", ImageSize -> 400, Background -> Gray]
Out[8]=

Properties and Relations

ResistorColorCode can accept the results of FromResistorColorCode as an argument:

In[9]:=
ResourceFunction["ResistorColorCode"][
 ResourceFunction["FromResistorColorCode"][{Red, Red, Blue}], "Graphics"]
Out[9]=

Resource History

Source Metadata

Related Resources

Author Notes

The following table can be used as a legend.

In[1]:=
Diagram[] = Column[{Grid[{{"", SpanFromLeft, Text@"digit", Text@"exponent", Text@"precision"}, {Text@"silver", Graphics[{LightGray, Rectangle[]}, ImageSize -> 13], "", -2, Row[{"\[PlusMinus]", Quantity[10, "Percent"]}]}, {Text@"gold", Graphics[{RGBColor[0.8144808117799649`, 0.710933089188983`, 0.12820630197604332`], Rectangle[]}, ImageSize -> 13], "", -1, Row[{"\[PlusMinus]", Quantity[5, "Percent"]}]}, {Text@
       "black", Graphics[{Black, Rectangle[]}, ImageSize -> 13], 0, 0,
       ""}, {Text@"brown", Graphics[{Brown, Rectangle[]}, ImageSize -> 13], 1, 1, Row[{"\[PlusMinus]", Quantity[1, "Percent"]}]}, {Text@"red", Graphics[{Red, Rectangle[]}, ImageSize -> 13], 2, 2, Row[{"\[PlusMinus]", Quantity[2, "Percent"]}]}, {Text@"orange", Graphics[{Orange, Rectangle[]}, ImageSize -> 13], 3, 3, ""}, {Text@"yellow", Graphics[{Yellow, Rectangle[]}, ImageSize -> 13], 4, 4, ""}, {Text@"green", Graphics[{Green, Rectangle[]}, ImageSize -> 13], 5, 5, Row[{"\[PlusMinus]", Quantity[.5, "Percent"]}]}, {Text@"blue", Graphics[{Blue, Rectangle[]}, ImageSize -> 13], 6, 6, Row[{"\[PlusMinus]", Quantity[.25, "Percent"]}]}, {Text@
       "purple", Graphics[{Purple, Rectangle[]}, ImageSize -> 13], 7, 7, Row[{"\[PlusMinus]", Quantity[.1, "Percent"]}]}, {Text@
       "gray", Graphics[{Gray, Rectangle[]}, ImageSize -> 13], 8, "", Row[{"\[PlusMinus]", Quantity[.05, "Percent"]}]}, {Text@"white",
       Graphics[{White, Rectangle[]}, ImageSize -> 13, Frame -> True, FrameTicks -> None], 9, "", ""}}, Alignment -> Center, Dividers -> All]}]

License Information