Sei sulla pagina 1di 18

LABSHEET 1

BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
lABSTRACT
Resistors are electrical components that resist
or regulate the flow of current in an electronic
circuit. Resistors are mainly used to protect
other electronic components from being
damaged due to high current. Besides, resistors
are also used to provide a specific voltage for an
active device. Other than variable resistors, all
resistors possess their own preset resistance
value. This value can be determined by the
bands on a resistor. Resistor can have 4 or 5
depending on the type. The color code on a
resistor is used to indicate its resistance value.
Manually determining the resistance value of a
resistor may be tiresome and time-consuming
sometimes. Hence, automatic resistance value
calculator can be used to make the task of
finding out the resistor value much simpler.
INTRODUCTION
We designed an application program using
Borland C++ Builder 6, which allow user to
calculate and determine the value of 4 band
and 5 band resistor. Borland C++ Builder 6 is a
programming environment for Microsoft
Windows. This application works by selecting
the color code corresponding to the resistor
whose value we want to determine, then
obtaining the resistor value clicking Calculator.
This program can be used to determine 4 band
and 5 band resistor depending on the option
chosen.
PROCEDURE
Before writing the coding for the
application program, an application interface

has to be designed first. Although, the interface


done follows the criteria and specifications set
by the labsheet instructions, we were free to
customize minor detail such as the adding of a
profile picture, and application background. A
number of requirements have to be fulfilled by
the GUI application programming which are:
a. Edit1, Edit2, Edit3, Edit4, and Edit 5
have to be initialized with value 0, and
Band1, Band2, Band3, Band4, Band5,
color has to be disappear.
b. Once the user makes a selection to 4
band, the color Band1, Band 2, Band3
and Band4 appears, while Band5
disappears. The band color must be
filled with clCream.
c. If the user make a selection to 5 Band,
all the color band should appear. The
color band will also be filled with cl
Cream.
d. Once the user clicks a color band
button, the code number will be
displayed in its respective Edit1, Edit2,
Edit3, Edit4, Edit5 box. Its value will be
displayed at Panel1, Panel2, Panel3,
Panel4, and Panel5. Moreover, the
color band will also be displayed at the
respective resistor color code band. The
actual
resistor
value
can
be
automatically calculated once the user
click Calculator button. The calculated
values comply with the resistor value

chart

as

shown

below.

4 Band selection

5 Band selection

Color band button

After click Reset button

e. The Reset button can be clicked to


clear the content in the Edit boxes and
the Panel boxes, Besides, the Reset
button also unchecks the RadioButton,
and resets the band color to the default
color.
f.

Lastly, tp exit the application program,


we can click Close button.

RESULTS
Application screenshoot:

After initializing application

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051

d) To determine the value of other


resistor, simply click the Reset button.
This will reset the application to its
initial condition. We then have to select
either 4 band or 5 band again.
e) Lastly, select the Close button to close
or exit the application.

DISCUSSION
1. The design of this application was done
according
to
the
labsheets
specification, while the coding was
done individually, with the guidance of
our lecturer.
2. There were some initial mistake or
error done when first developing the
application coding, but they were
successfully resolved at the end.
3. This application is user-friendly in that it
is easy to use. The step to use this
application is as listed below.

CONCLUSION
The creation of an automatic resistor value
calculator application is an easier way to
determine a resistors resistance value,
compared to traditional manual methods.
This application not only saves time, but
effort as well, when trying to determine the
resistors value. In addition, hassle is also
reduced since users do not need to
remember or refer to the resistor color
value chart. The use of the programming
software Borland C++ Builder 6 is fairly
simple and straight-forward when designing
and developing this application.

How to use the application:


a) Select either 4 band or 5 band for a 4
band and 5 band resistor respectively.
b) Select the color of the first resistor band
at the Band box, according to the
resistor whose value we want to
determine. Do this for the other bands
as well.
c) After selecting the band color, click the
Calculator button to get the actual
value of the resistor.

ACKNOWLEDGEMENT
I would like to thank my BEE3931 PC
INTERFACINGs lecturer, En. Mohd Falfazli
Bin Mat Jusoh for teaching me the basics of
PC Interfacing and how to use the Borland
C++ Builder 6 software, as well as his
guidance during the designing and
developing stage of this application
program. Besides, I also would like to thank

my friend for their advice and support. With


the help of my lecturer and friend, I was
able to complete this lab assignment
successfully and on time. My sincere thanks
and appreciation to the aforementioned
people.

REFERENCES
a) BEE3931 notes from En, Mohd Falfazli
Bin Mat Jusoh
b) https://www.yevol.com/bcb/lesson24.h
tm

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
void __fastcall
*Sender)

TForm1::FormCreate(TObject

{
Appendix
//--------------------------------------------------------------------------

Edit1->Text="0";
Edit2->Text="0";
Edit3->Text="0";
Edit4->Text="0";

#include <vcl.h>

Edit5->Text="0";

#pragma hdrstop

Panel1->Caption="0";
Panel2->Caption="0";

#include "hafiz.h"

Panel3->Caption="0";

//--------------------------------------------------------------------------

Panel4->Caption="0";

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//-------------------------------------------------------------------------__fastcall
Owner)

TForm1::TForm1(TComponent*

: TForm(Owner)

Panel5->Caption="0";
Panel6->Caption="0";
Shape2->Visible=false;
Shape3->Visible=false;
Shape4->Visible=false;
Shape5->Visible=false;
Shape6->Visible=false;
Button1->Caption="Calculator";

Button4->Caption="0 Black";

Button5->Caption="1 Brown";

//--------------------------------------------------------------------------

Button6->Caption="2 Red";

Button7->Caption="3 Orange";

Button32->Caption="8 Silver";

Button8->Caption="4 Yellow";

Button33->Caption="9 White";

Button9->Caption="5 Green";

Button34->Caption="0 Black";

Button10->Caption="6 Blue";

Button35->Caption="1 Brown";

Button11->Caption="7 Purple";

Button36->Caption="2 Red";

Button12->Caption="8 Silver";

Button37->Caption="3 Orange";

Button13->Caption="9 White";

Button38->Caption="4 Yellow";

Button14->Caption="0 Black";

Button39->Caption="5 Green";

Button15->Caption="1 Brown";

Button40->Caption="6 Blue";

Button16->Caption="2 Red";

Button41->Caption="7 Purple";

Button17->Caption="3 Orange";

Button42->Caption="8 Silver";

Button18->Caption="4 Yellow";

Button43->Caption="10 Gold";

Button19->Caption="5 Green";

Button44->Caption="1 Brown";

Button20->Caption="6 Blue";

Button45->Caption="2 Red";

Button21->Caption="7 Purple";

Button46->Caption="3 Green";

Button22->Caption="8 Silver";

Button47->Caption="4 Blue";

Button23->Caption="9 White";

Button48->Caption="5 Purple";

Button24->Caption="0 Black";

Button49->Caption="6 Grey";

Button25->Caption="1 Brown";

Button50->Caption="7 Gold";

Button26->Caption="2 Red";

Button51->Caption="8 Silver";

Button27->Caption="3 Orange";

Shape1->Brush->Color=clSilver;

Button28->Caption="4 Yellow";

Button1->Caption="Calculator";

Button29->Caption="5 Green";

Button2->Caption="Reset";

Button30->Caption="6 Blue";

Button3->Caption="Close";

Button31->Caption="7 Purple";

RadioButton1->Caption="4 Band";

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
RadioButton2->Caption="5 Band";

Label4->Caption="Multiplier";

Label10->Caption="Total";

Label5->Caption="Tolerance";

Label1->Caption="Band 1";
Label2->Caption="Band 2";

Label3->Caption="Band 3";

//--------------------------------------------------------------------------

Label4->Caption="Multiplier";
Label5->Caption="Tolerance";

void
__fastcall
TForm1::RadioButton1Click(TObject *Sender)

Label6->Caption="Resistor Color Band";

Label7->Caption="Code No";

Shape2->Visible=false;

Label8->Caption="Value";

Shape3->Visible=true;

Label9->Caption="Ohm";

Shape4->Visible=true;

GroupBox2->Caption="Band1";

Shape5->Visible=true;

GroupBox3->Caption="Band2";

Shape6->Visible=true;

GroupBox4->Caption="Band3";

Shape2->Brush->Color=clCream;

GroupBox5->Caption="Multiplier";

Shape3->Brush->Color=clCream;

GroupBox1->Caption="Tolerance";

Shape4->Brush->Color=clCream;

GroupBox1->Enabled=false;

Shape5->Brush->Color=clCream;

GroupBox2->Enabled=false;

GroupBox1->Enabled=true;

GroupBox3->Enabled=false;

GroupBox2->Enabled=false;

GroupBox4->Enabled=false;

GroupBox3->Enabled=true;

GroupBox5->Enabled=false;

GroupBox4->Enabled=true;

Label2->Caption="Band 1";

GroupBox5->Enabled=true;

Label3->Caption="Band 2";

Edit1->Text="0";

Panel1->Caption="0";

GroupBox5->Enabled=true;

Label1->Caption="";

Label1->Caption="Band 1";

Label2->Caption="Band 1";

Label2->Caption="Band 2";

Label3->Caption="Band 2";

Label3->Caption="Band 3";

Label4->Caption="Multiplier";

Label4->Caption="Multiplier";

Label5->Caption="Tolerance";

Label5->Caption="Tolerance";

//--------------------------------------------------------------------------

//--------------------------------------------------------------------------

void
__fastcall
TForm1::RadioButton2Click(TObject *Sender)

void __fastcall TForm1::Button4Click(TObject


*Sender)

Shape2->Visible=true;

Edit1->Text="0";

Shape3->Visible=true;

Panel1->Caption="0";

Shape4->Visible=true;

Shape2->Brush->Color=clBlack;

Shape5->Visible=true;
Shape6->Visible=true;

Shape2->Brush->Color=clCream;

//--------------------------------------------------------------------------

Shape3->Brush->Color=clCream;
Shape4->Brush->Color=clCream;

void __fastcall TForm1::Button5Click(TObject


*Sender)

Shape5->Brush->Color=clCream;

Shape6->Brush->Color=clCream;

Edit1->Text="1";

GroupBox1->Enabled=true;

Panel1->Caption="100";

GroupBox2->Enabled=true;

Shape2->Brush->Color=clMaroon;

GroupBox3->Enabled=true;

GroupBox4->Enabled=true;

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
//-------------------------------------------------------------------------void __fastcall TForm1::Button6Click(TObject
*Sender)
{

Shape2->Brush->Color=clYellow;
}
//--------------------------------------------------------------------------

Edit1->Text="2";

void __fastcall TForm1::Button9Click(TObject


*Sender)

Panel1->Caption="200";

Shape2->Brush->Color=clRed;

Edit1->Text="5";

Panel1->Caption="500";

//--------------------------------------------------------------------------

Shape2->Brush->Color=clGreen;

void __fastcall TForm1::Button7Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit1->Text="3";

void __fastcall TForm1::Button10Click(TObject


*Sender)

Panel1->Caption="300";

Shape2->Brush->Color=clAqua;

Edit1->Text="6";

Panel1->Caption="600";

//--------------------------------------------------------------------------

Shape2->Brush->Color=clBlue;

void __fastcall TForm1::Button8Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit1->Text="4";

void __fastcall TForm1::Button11Click(TObject


*Sender)

Panel1->Caption="400";

Edit1->Text="7";

Panel2->Caption="0";

Panel1->Caption="700";

Shape3->Brush->Color=clBlack;

Shape2->Brush->Color=clPurple;

//--------------------------------------------------------------------------

//-------------------------------------------------------------------------void __fastcall TForm1::Button12Click(TObject


*Sender)

void __fastcall TForm1::Button15Click(TObject


*Sender)
{

Edit2->Text="1";

Edit1->Text="8";

Panel2->Caption="10";

Panel1->Caption="800";

Shape3->Brush->Color=clMaroon;

Shape2->Brush->Color=clSilver;

//--------------------------------------------------------------------------

//-------------------------------------------------------------------------void __fastcall TForm1::Button13Click(TObject


*Sender)

void __fastcall TForm1::Button16Click(TObject


*Sender)
{

Edit2->Text="2";

Edit1->Text="9";

Panel2->Caption="20";

Panel1->Caption="900";

Shape3->Brush->Color=clRed;

Shape2->Brush->Color=clWhite;

//--------------------------------------------------------------------------

//-------------------------------------------------------------------------void __fastcall TForm1::Button14Click(TObject


*Sender)

void __fastcall TForm1::Button17Click(TObject


*Sender)
{

Edit2->Text="3";

Edit2->Text="0";

Panel2->Caption="30";

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
Shape3->Brush->Color=clAqua;

Edit2->Text="6";

Panel2->Caption="60";

//--------------------------------------------------------------------------

Shape3->Brush->Color=clBlue;

void __fastcall TForm1::Button18Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit2->Text="4";

void __fastcall TForm1::Button21Click(TObject


*Sender)

Panel2->Caption="40";

Shape3->Brush->Color=clYellow;

Edit2->Text="7";

Panel2->Caption="70";

//--------------------------------------------------------------------------

Shape3->Brush->Color=clPurple;

void __fastcall TForm1::Button19Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit2->Text="5";

void __fastcall TForm1::Button22Click(TObject


*Sender)

Panel2->Caption="50";

Shape3->Brush->Color=clGreen;

Edit2->Text="8";

Panel2->Caption="80";

//--------------------------------------------------------------------------

Shape3->Brush->Color=clSilver;

void __fastcall TForm1::Button20Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button23Click(TObject


*Sender)

void __fastcall TForm1::Button26Click(TObject


*Sender)

Edit2->Text="9";

Edit3->Text="2";

Panel2->Caption="90";

Panel3->Caption="2";

Shape3->Brush->Color=clWhite;

Shape4->Brush->Color=clRed;

//--------------------------------------------------------------------------

//--------------------------------------------------------------------------

void __fastcall TForm1::Button24Click(TObject


*Sender)

void __fastcall TForm1::Button27Click(TObject


*Sender)

Edit3->Text="0";

Edit3->Text="3";

Panel3->Caption="0";

Panel3->Caption="3";

Shape4->Brush->Color=clBlack;

Shape4->Brush->Color=clAqua;

//--------------------------------------------------------------------------

//--------------------------------------------------------------------------

void __fastcall TForm1::Button25Click(TObject


*Sender)

void __fastcall TForm1::Button28Click(TObject


*Sender)

Edit3->Text="1";

Edit3->Text="4";

Panel3->Caption="1";

Panel3->Caption="4";

Shape4->Brush->Color=clMaroon;

Shape4->Brush->Color=clYellow;

//--------------------------------------------------------------------------

//--------------------------------------------------------------------------

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
void __fastcall TForm1::Button29Click(TObject
*Sender)

//--------------------------------------------------------------------------

void __fastcall TForm1::Button32Click(TObject


*Sender)

Edit3->Text="5";
Panel3->Caption="5";
Shape4->Brush->Color=clGreen;
}
//--------------------------------------------------------------------------

{
Edit3->Text="8";
Panel3->Caption="8";
Shape4->Brush->Color=clSilver;
}

void __fastcall TForm1::Button30Click(TObject


*Sender)

//--------------------------------------------------------------------------

void __fastcall TForm1::Button33Click(TObject


*Sender)

Edit3->Text="6";
Panel3->Caption="6";
Shape4->Brush->Color=clBlue;
}
//--------------------------------------------------------------------------

{
Edit3->Text="9";
Panel3->Caption="9";
Shape4->Brush->Color=clWhite;
}

void __fastcall TForm1::Button31Click(TObject


*Sender)

//--------------------------------------------------------------------------

void __fastcall TForm1::Button34Click(TObject


*Sender)

Edit3->Text="7";
Panel3->Caption="7";
Shape4->Brush->Color=clPurple;
}

{
Edit4->Text="0";
Panel4->Caption="1 ";

Shape5->Brush->Color=clBlack;
}

//--------------------------------------------------------------------------

//-------------------------------------------------------------------------void __fastcall TForm1::Button35Click(TObject


*Sender)
{
Edit4->Text="1";

void __fastcall TForm1::Button37Click(TObject


*Sender)

Panel4->Caption="10";

Shape5->Brush->Color=clMaroon;

Edit4->Text="3";

Panel4->Caption="1000";

//--------------------------------------------------------------------------

Shape5->Brush->Color=clAqua;

void __fastcall TForm1::Button36Click(TObject


*Sender)

}
//--------------------------------------------------------------------------

{
Edit4->Text="2";
Panel4->Caption="100";

void __fastcall TForm1::Button38Click(TObject


*Sender)

Shape5->Brush->Color=clRed;

Edit4->Text="4";

//--------------------------------------------------------------------------

Panel4->Caption="10000";
Shape5->Brush->Color=clYellow;

void __fastcall TForm1::Button3Click(TObject


*Sender)

//--------------------------------------------------------------------------

Close();
}

void __fastcall TForm1::Button39Click(TObject


*Sender)

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
{
Edit4->Text="5";

//--------------------------------------------------------------------------

Panel4->Caption="100000";
Shape5->Brush->Color=clGreen;

void __fastcall TForm1::Button42Click(TObject


*Sender)

//--------------------------------------------------------------------------

Edit4->Text="8";
Panel4->Caption="0.01";

void __fastcall TForm1::Button40Click(TObject


*Sender)
{
Edit4->Text="6";

Shape5->Brush->Color=clSilver;
}
//--------------------------------------------------------------------------

Panel4->Caption="1000000";
Shape5->Brush->Color=clBlue;

void __fastcall TForm1::Button43Click(TObject


*Sender)

//--------------------------------------------------------------------------

Edit4->Text="10";
Panel4->Caption="0.1";

void __fastcall TForm1::Button41Click(TObject


*Sender)
{
Edit4->Text="7";
Panel4->Caption="10000000";
Shape5->Brush->Color=clPurple;
}

Shape5->Brush->Color=clFuchsia;
}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button44Click(TObject


*Sender)

//--------------------------------------------------------------------------

{
Edit5->Text="1";
Panel5->Caption="+/-1%";
Shape6->Brush->Color=clMaroon;
}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button46Click(TObject


*Sender)
{
Edit5->Text="3";
Panel5->Caption="+/-0.5%";
Shape6->Brush->Color=clGreen;

void __fastcall TForm1::Button45Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit5->Text="2";
Panel5->Caption="+/-2%";
Shape6->Brush->Color=clRed;
}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button48Click(TObject


*Sender)
{
Edit5->Text="5";
Panel5->Caption="+/-0.1%";
Shape6->Brush->Color=clPurple;

void __fastcall TForm1::Button47Click(TObject


*Sender)
{

}
//--------------------------------------------------------------------------

Edit5->Text="4";
Panel5->Caption="+/-0.25%";
Shape6->Brush->Color=clBlue;
}

void __fastcall TForm1::Button49Click(TObject


*Sender)
{
Edit5->Text="6";

LABSHEET 1
BEE3931 PC INTERFACING
MAULANA ZULFIKAR BIN ASRIL
EC12051
Panel5->Caption="+/-0.05%";
Shape6->Brush->Color=clSkyBlue;
}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject


*Sender)
{
Edit1->Text="0";
Edit2->Text="0";

void __fastcall TForm1::Button50Click(TObject


*Sender)
{
Edit5->Text="7";
Panel5->Caption="+/-5%";
Shape6->Brush->Color=clFuchsia;
}
//--------------------------------------------------------------------------

Edit3->Text="0";
Edit4->Text="0";
Edit5->Text="0";
Panel1->Caption="0";
Panel2->Caption="0";
Panel3->Caption="0";
Panel4->Caption="0";
Panel5->Caption="0";
Panel6->Caption="0";

void __fastcall TForm1::Button51Click(TObject


*Sender)

Shape2->Brush->Color=clCream;

Shape4->Brush->Color=clCream;

Edit5->Text="8";

Shape5->Brush->Color=clCream;

Panel5->Caption="+/-10%";

Shape6->Brush->Color=clCream;

Shape6->Brush->Color=clSilver;

RadioButton1->Checked=false;

RadioButton2->Checked=false;

//--------------------------------------------------------------------------

Shape3->Brush->Color=clCream;

}
//--------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject


*Sender)
{
double Value1, Value2, Value3, Value4, Total;

Value1=Panel1->Caption.ToDouble();
Value2=Panel2->Caption.ToDouble();
Value3=Panel3->Caption.ToDouble();
Value4=Panel4->Caption.ToDouble();

Total=(Value1+Value2+Value3)*Value4;
Panel6->Caption=Total;

}
//--------------------------------------------------------------------------

Potrebbero piacerti anche