Introduction: Resistor Calculator Using RGB Leds

It is common to have a lot of messy different resistors and you want a specific value but you don't memorize the resistor color code .

In this project I tried to solve this problem by making a circuit using Arduino which allows you to enter the value of resistor you want and you have the color code as an output in more than one method:

  • On serial monitor (Arduino IDE) as a text.
  • Using 3 RGB LEDs.

You can input the values using:

  • Serial monitor
  • Keypad.

For more demonstration see the video (Sorry for my bad English :) )
 

Step 1: Part List

Picture of Part List
  • Arduino or any compatible device /1/ (I used a clone named SHAMduino we produce from local resources in the company I works at named Atadiat ).
  • Keypad /1/.
  • RGB LEDs /3/.
  • Demultiplexer CD4053 /2/.
  • Seven segments 3 digits /1/ Seven segment driver HEF4543B /1/.
  • Resistor 470 ohm /12/.
  • Testboard /1/.
  • Wires and jumpers.

Step 2: Hardware Details

Picture of  Hardware Details
  • Arduino

Most of you know this popular platform which I find the best choice for building fast prototypes before switching to raw electronics using microcontrollers and PCBs.

  • Keypad

this component is the input device of this project which consist of raws and columns (ex:4×4) , the numbers of pins is equal to the numbers of raws+columns. The reason of that is demonstrated in an attached picture.

  • RGB LED

this kind of LED is consist of internal leds which are:red,green and blue . we can produce almost any color we want using a mix of Red ,Green and Blue. For example if we want to have a white color we must switch ON the 3 internal leds. The pin-out of this kind of RGB is given by an attached picture.

(NOTE: there are 2 types of RGB led, common anode and common cathode ).

  • Demultiplexer

You will see that the pins of Arduino will run-out, so I must reduce the number of used pins, so I used a demultiplexer for this purpose.By using this demultiplexer I will need 3 pins as an output for RED , green and blue pins if the RGB LEDs , 1 pin for selecting channel inside every chip and 2 pin to avtice/de-active chips .

Without using this demultiplexer I will need 9 pins to drive the RGB LEDs.

If you don't know what demultiplexer is, you can imagine it as a switch, which can switch between to channel every channel have 3 input/output , with common input .

The reason I used 2 of CD4053 is that every chip have 2 channel and I need 3 triple channel ,so I used 2 of them. So when I need to output some color the enable loop will be like this :

  • //first led
    channel 1 chip 1 (on)
    channel 2 chip 1 (off)
    chip 2 (off)
  • //second led
    channel 1 chip 1 (off)
    channel 2 chip 1 (on)
    chip 2 (off)
  • //third led
    chip 1 (off)
    channel 1 chip 2 (on)
  • Seven segment driver

Also I used the driver to reduce the number of required pins to drive 7seg from 7 to 4 pins . One more feature about HEF4543B is than I can control the output of this chip if I have common anode or cathode 7seg .

The reason behind using 7seg is for future development, to make the device portable to see the entry using 7seg or other stuff.

Step 3: Software Details

The sketch behind this project is consist of the following functions

  • seven_seg_disp(int num)
  • rgbled(int r,int g,int b)
  • colortorgb(int color)
  • rgbdisp()
  • printbandcolor(int band)
  • value()
  • start()

Before explaining every function lets understand the code and how it works:

  1. First in the loop function you can see a while loop with condition DO==TRUE.
    DO is a key for execution , with initial value FALSE .If user didn't finish correctly DO will not change to true.
    keys is important to make sure that some codes doesn't execute unless I unlock the key.
  2. Then you will find 2 structures: first is IF and the second is FOR.
    IF is used to make sure that FOR doesn't execute unless user press '*', which make DO2 (the key of FOR loop) TRUE.
    These tow structure is dedicated to keypad input method. In the FOR loop user may finish the entry by pressing '*' tow times, because some times user have one digit to input like 1 ohm.
  3. You can see in both input method -keypad and serial monitor- that I used a counter numofdigits, the reason is related to manipulating the entered values (in function called value()).

  4. Input from keypad or computer is coded using “ASCII” so to get the real value we must subtract it from '0' value in ASCII.
Now lets talk about every function: seven_seg_disp(int num)

Output the D0-D3 on Arduino pins connected to 7seg driver.

rgbled(int r,int g,int b)

Output the arguments to RGB pins connected to Arduino.

colortorgb(int color)
Convert numeric value of resistor bands to RGB color.

rgbdisp()
Output function for both 7seg or RGB leds ,it activated and deactivate demultiplexers and channels alternatively as what I explained in hardware details.

printbandcolor(int band)
Printing the color code of every band on Serial monitor.

Value()
Manipulating entered values according to possibilities of entries and store the values in matrix called colorcode.

start()
To make sure that some values return to initial value especially digits matrix which is used for entry and must by blank every time we enter new values.

Step 4: Build It !

Picture of Build It !

You have the code and the connection diagram attached,TRY IT :)

Also don't forget to read the sketch to learn new things from it and read the comments.

If you like the Idea and want to contribute , you are welcome and you can do that using github .

Comments

Gabrielle031212 (author)2014-03-23

thank ya im a scientist i oughta try this not...

About This Instructable

2,705views

12favorites

License:

Bio: interested in open hardware and digital fabrication co-founder of atadiat مهتم بالعتاد مفتوح المصدر و التصنيع الرقمي
More by yahyatawil:How to Make a Circuit Board With EasyEDAresistor calculator using RGB leds
Add instructable to: