You are on page 1of 10

Mohammed Alqatan 11901945

Ahmad Almomen 11800012

Muath Abdulaziz AL idel 11701322

Tariq Adossary 11602499

EGR301 Project: Color-coding Technique in Resistors.

Section: 1

Instructor: Dr. Saed Alsayigh


Introduction:

In a color-coding technique, the resistors value is marked on the resistors body by using colors. The colors

painted on the resistors body are called color bands. All the color bands painted on the resistor body are used

to indicate the resistance value and tolerance. The 1st color band on the resistor denotes the first significant

value or first digit of the resistor’s resistance and the second color band denotes second significant value or

second digit of the resistor’s resistance. The third color band is the decimal multiplier, and the fourth color

band shows the resistors tolerance. The first along with second color bands collectively make it to up a two-

digit number and the third color band or multiplier is multiplied with this two-digit number to achieve the

resistance value of the resistor.

Fig: 4-band resistor [1]


Each color on the resistors body represents a different number. We are going to implement this technique on

MATLAB software with given chart.

Objective:

The main objective of this project is to implement a MATLAB program that calculates

resistance of a resistor from the color code.

Methodology:

The following are the main steps in MATLAB CODE used in the carrying out the projects:

• In first step we asked user input as data type string

• In the second step used switched statement to achieve the desired output regarding 4

different bands

• We used 4 switch case to accomplished target

• And in the end display the data using fprintf


Algorithm:

Pseudo Code is given below:

Take Band1 as input

Check and Compare the strings and assign the value accordingly

Take Band2 as input

Check and Compare the strings and assign the value accordingly

Take Band3 as input

Check and Compare the strings and assign the value accordingly

Take Band3 as input for the tolerance value

Check and Compare the strings and assign the value accordingly

Then calculate the resistor value using the formula Resistor = Band1*Band3*10+Band2*Band3

Calculate the tolerance limits using the formula Resistor*Band4

Flowchart
MATLAB CODE
% for Band-1

Band1 = input('Enter Band 1 Color: ','s');

switch true

case strcmp(Band1,'brown') == 1

B1 = 1;

case strcmp(Band1,'red') == 1

B1 = 2;

case strcmp(Band1,'orange') == 1

B1 = 3;

case strcmp(Band1,'yellow') == 1

B1 = 4;

case strcmp(Band1,'green') == 1

B1 = 5;

case strcmp(Band1,'blue') == 1

B1 = 6;

case strcmp(Band1,'voilet') == 1

B1 = 7;

case strcmp(Band1,'gray') == 1

B1 = 8;

case strcmp(Band1,'white') == 1

B1 = 9;

otherwise

disp('Entered wrong input...........!!!!');

end
% for Band-2

Band2 = input('Enter Band 2 Color: ','s');

switch true

case strcmp(Band2,'black') == 1

B2 = 0;

case strcmp(Band2,'brown') == 1

B2 = 1;

case strcmp(Band2,'red') == 1

B2 = 2;

case strcmp(Band2,'orange') == 1

B2 = 3;

case strcmp(Band2,'yellow') == 1

B2 = 4;

case strcmp(Band2,'green') == 1

B2 = 5;

case strcmp(Band2,'blue') == 1

B2 = 6;

case strcmp(Band2,'voilet') == 1

B2 = 7;

case strcmp(Band2,'gray') == 1

B2 = 8;

case strcmp(Band2,'white') == 1

B2 = 9;

otherwise

disp('Entered wrong input...........!!!!');

end

% for Band-3
Band3 = input('Enter Band 3 Color: ','s');

switch true

case strcmp(Band3,'black') == 1

B3 = 0;

case strcmp(Band3,'brown') == 1

B3 = 10;

case strcmp(Band3,'red') == 1

B3 = 100;

case strcmp(Band3,'orange') == 1

B3 = 1000;

case strcmp(Band3,'yellow') == 1

B3 = 10000;

case strcmp(Band3,'green') == 1

B3 = 100000;

case strcmp(Band3,'blue') == 1

B3 = 1000000;

case strcmp(Band3,'voilet') == 1

B3 = 10000000;

case strcmp(Band3,'gray') == 1

B3 = 100000000;

case strcmp(Band3,'white') == 1

B3 = 1000000000;

otherwise

disp('Entered wrong input...........!!!!');

end

% for Band-4
Band4 = input('Enter Band 4 Color: ','s');

switch true

case strcmp(Band4,'None') == 1

B4 = 0.2;

case strcmp(Band4,'silver') == 1

B4 = 0.1;

case strcmp(Band4,'gold') == 1

B4 = 0.05;

otherwise

disp('Entered wrong input!!');

end

R = B1*B3*10 + B2*B3;

R_H = R+R*B4;

R_L = R-R*B4;

fprintf('\n\nResistance Value is: %d Ohms\n',R)

fprintf('Resistance Value range is: %d to %d Ohms\n',R_L,R_H);


Testing and Results

Test 1

Test 2

Conclusion:

It is concluded that we leaned that MATLAB software is a very efficient software to get

desired program. And this language syntax is very proficient as compared to other

programming languages. In this project, we efficiently implemented color band technique in

MATLAB using switch cases and four input prompts, and we got the perfect and accurate

desired result. Band 5 and 6 technique can also implement in MATLAB as improvement in

existing program.
References:

1. Shaik, A., 2020. Resistor Color Code - 4 Band, 5 Band And 6 Band Resistors. [online] Physics-and-

radio-electronics.com. Available at: <https://www.physics-and-radio-electronics.com/electronic-

devices-and-circuits/passive components/resistors/

resistorcolorcode.html#:~:text=In%20a%20color%20coding%20technique,the%20resistance%20val

ue%20and%20tolerance.> [Accessed 10-Dec 2020].

You might also like