Sie sind auf Seite 1von 16

LABSHEET 2

BEE3931 PC INTERFACING
ABSTRACT
Digital is a quantity is represented by symbols
called digits. Digital output is the best way to
express the value. It is more accurate and more
simples. Examples: digital watch, digital meter.
Digital Electronic is a combination of devices
designed to manipulate physical quantities that
are represented in digital form. Advantages of
digital systems:

Generally easier to design

Information storage is easy

Accuracy and precision are easier to


maintain

More digital circuitry can be fabricated


on IC chip

Less affected by noise.

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:
For part 1

a.

When you click for example Digital


Output 1 button, LED output will turn
ON and indication at GUI will change
from red color (OFF) to green color
(ON).
b. If LED indication in red color, control
button will display Click to ON.
But, if LED indication in green color,
control button will display Click to
OFF.
c. Status will update condition of LED
whether ON or OFF.
d. You can control activation of LED
output independently
e. You may use any suitable component
to complete this task.

INTRODUCTION
We designed an application program using
Borland C++ Builder 6, which allow user to apply
digital output and digital input configuration.
Borland C++ Builder 6 is a programming
environment for Microsoft Windows. This
application works by selecting the control
button Digital Output and the output will
display using LED. This program can be used to
display output from 0 to 9.
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

RESULTS
Application screen shoot:

After initializing application

b) Every time when user select a switch to


display a selected number, at the same time,
message box will display to remind user that
user already switch ON that switch. For
example, message box will display with a
message USER SWITCH ON CHANNEL 8.
ARE YOU SURE?.
c) If user click button NO button at message
box, system will reset. Nothing happen to 7
segment display. But if user click YES button
at message box, then 7 segment display at both
hardware and GUI will show a value for the
selected switch refer to table as above.
d) At one time, only one channel can be selected
to turn ON.

When click button Click to ON at


Digital Output 0

e) You may use any suitable component to


complete this task.

When click button Click to ON, the button


display Click to OFF and the LED output show
green light and the status show ON. When click
the other button, it shows the same result.
For part 2
a) Display at 7 segment display will be same
with the display at GUI refer to condition table
as above.

RESULTS
Application screen shoot:

After initializing application

LABSHEET 2
BEE3931 PC INTERFACING

When click button Click to ON at


Digital Output 0

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

When click button Yes

When click button Click to ON the message


box appear for a conformation. Need to click
button Yes to make the 7 segment display
show 0. When click the other button, it shows
the same result.

DISCUSSION

The creation of this program is to study


about and apply digital output and digital
input configuration. We also need to learn
how to do integration between DAQ card
and software programming. This application
not only saves time, but effort as well. In
addition, the use of the programming
software Borland C++ Builder 6 is fairly
simple and straight-forward when designing
and developing this application.

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

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

LABSHEET 2
BEE3931 PC INTERFACING
Appendix:

Panel5->Caption="7 SEGMENT DISPLAY";

#include <vcl.h>

Button1->Caption="Click to ON";

#pragma hdrstop

Button2->Caption="Click to ON";
Button3->Caption="Click to ON";

#include "Lab2.h"

Button4->Caption="Click to ON";

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

Button5->Caption="Click to ON";

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

Button6->Caption="Click to ON";
Button7->Caption="Click to ON";
Button8->Caption="Click to ON";
Button17->Caption="Click to ON";
Button9->Caption="Click to OFF";
Button18->Caption="Click to OFF";
Button10->Caption="Click to OFF";
Button11->Caption="Click to OFF";

Button12->Caption="Click to OFF";

Button13->Caption="Click to OFF";

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

Button14->Caption="Click to OFF";

void __fastcall TForm1::FormCreate(TObject


*Sender)

Button15->Caption="Click to OFF";
Button16->Caption="Click to OFF";

Button9->Visible=false;

Panel1->Caption="Control Button";

Button10->Visible=false;

Panel2->Caption="LED Output";

Button11->Visible=false;

Panel3->Caption="Status";

Button12->Visible=false;

Panel4->Caption="SWITCH CONDITION";

Button13->Visible=false;

Button14->Visible=false;

Label12->Caption="OFF";

Button15->Visible=false;

Label13->Caption="OFF";

Button16->Visible=false;

Label14->Caption="OFF";

Button18->Visible=false;

Label15->Caption="OFF";

Shape1->Brush->Color=clRed;

Label16->Caption="OFF";

Shape2->Brush->Color=clRed;

Label17->Caption="";

Shape3->Brush->Color=clRed;

Label18->Caption="";

Shape4->Brush->Color=clRed;
Shape5->Brush->Color=clRed;

Shape6->Brush->Color=clRed;

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

Shape7->Brush->Color=clRed;
Shape8->Brush->Color=clRed;

void __fastcall TForm1::Button1Click(TObject


*Sender)

Shape23->Brush->Color=clRed;

Label1->Caption="Digital Output 0";

Label2->Caption="Digital Output 1";

Label4->Caption="Digital Output 3";

Application->MessageBoxA("USER SWITCH ON
CHANNEL 0.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|

Label5->Caption="Digital Output 4";

MB_DEFBUTTON1)==IDYES;

Label6->Caption="Digital Output 5";

Shape1->Brush->Color=clGreen;

Label7->Caption="Digital Output 6";

Label9->Caption="ON";

Label8->Caption="Digital Output 7";

Button9->Visible=true;

Label19->Caption="Digital Output 8";

Label17->Caption="SWITCH 0 ON";

Label9->Caption="OFF";

Label18->Caption="SWITCH 0 ON";

Label10->Caption="OFF";

Shape9->Brush->Color=clRed;

Label11->Caption="OFF";

Shape10->Brush->Color=clRed;

Label3->Caption="Digital Output 2";

LABSHEET 2
BEE3931 PC INTERFACING
Shape11->Brush->Color=clRed;

Shape11->Brush->Color=clWhite;

Shape13->Brush->Color=clRed;

Shape12->Brush->Color=clWhite;

Shape14->Brush->Color=clRed;

Shape13->Brush->Color=clWhite;

Shape15->Brush->Color=clRed;

Shape14->Brush->Color=clWhite;

Shape16->Brush->Color=clRed;

Shape15->Brush->Color=clWhite;

Shape17->Brush->Color=clRed;

Shape16->Brush->Color=clWhite;

Shape18->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape20->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

Shape21->Brush->Color=clRed;

Shape19->Brush->Color=clWhite;

Shape22->Brush->Color=clRed;

Shape20->Brush->Color=clWhite;

Shape21->Brush->Color=clWhite;

Shape22->Brush->Color=clWhite;

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

void __fastcall TForm1::Button9Click(TObject


*Sender)
{

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

Shape1->Brush->Color=clRed;

void __fastcall TForm1::Button2Click(TObject


*Sender)

Label9->Caption="OFF";

Button9->Visible=false;

Label17->Caption="";

Shape9->Brush->Color=clWhite;

Application->MessageBoxA("USER SWITCH ON
CHANNEL 1.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|

Shape10->Brush->Color=clWhite;

MB_DEFBUTTON1)==IDYES;

Label18->Caption="";

Shape2->Brush->Color=clGreen;

Shape12->Brush->Color=clWhite;

Label10->Caption="ON";

Shape13->Brush->Color=clWhite;

Button10->Visible=true;

Shape14->Brush->Color=clWhite;

Label17->Caption="";

Shape15->Brush->Color=clWhite;

Label17->Caption="SWITCH 1 ON";

Shape16->Brush->Color=clWhite;

Shape10->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape13->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

Shape17->Brush->Color=clRed;

Shape19->Brush->Color=clWhite;

Shape20->Brush->Color=clRed;

Shape20->Brush->Color=clWhite;

Label18->Caption="SWITCH 1 ON";

Shape21->Brush->Color=clWhite;

Shape22->Brush->Color=clWhite;

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

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

void __fastcall TForm1::Button10Click(TObject


*Sender)

void __fastcall TForm1::Button3Click(TObject


*Sender)

Shape2->Brush->Color=clRed;

Label10->Caption="OFF";

Label17->Caption="";

Application->MessageBoxA("USER SWITCH ON
CHANNEL 2.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|

Label18->Caption="";

MB_DEFBUTTON1)==IDYES;

Shape9->Brush->Color=clWhite;

Shape3->Brush->Color=clGreen;

Shape10->Brush->Color=clWhite;

Label11->Caption="ON";

Shape11->Brush->Color=clWhite;

Button11->Visible=true;

Button10->Visible=false;

LABSHEET 2
BEE3931 PC INTERFACING
Shape9->Brush->Color=clRed;

Shape11->Brush->Color=clWhite;

Shape10->Brush->Color=clRed;

Shape12->Brush->Color=clWhite;

Shape12->Brush->Color=clRed;

Shape13->Brush->Color=clWhite;

Shape15->Brush->Color=clRed;

Shape14->Brush->Color=clWhite;

Shape14->Brush->Color=clRed;

Shape15->Brush->Color=clWhite;

Shape21->Brush->Color=clRed;

Shape16->Brush->Color=clWhite;

Shape22->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape19->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

Shape17->Brush->Color=clRed;

Shape19->Brush->Color=clWhite;

Shape16->Brush->Color=clRed;

Shape20->Brush->Color=clWhite;

Label17->Caption="SWITCH 2 ON";

Shape21->Brush->Color=clWhite;

Label18->Caption="SWITCH 2 ON";

Shape22->Brush->Color=clWhite;

Label17->Caption="";

Label18->Caption="";

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

void __fastcall TForm1::Button11Click(TObject


*Sender)

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

void __fastcall TForm1::Button4Click(TObject


*Sender)

Shape3->Brush->Color=clRed;

Label11->Caption="OFF";

Button11->Visible=false;

Application->MessageBoxA("USER SWITCH ON
CHANNEL 3.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|

Shape9->Brush->Color=clWhite;
Shape10->Brush->Color=clWhite;

MB_DEFBUTTON1)==IDYES;

Button12->Visible=false;

Shape4->Brush->Color=clGreen;

Shape9->Brush->Color=clWhite;

Label12->Caption="ON";

Shape10->Brush->Color=clWhite;

Button12->Visible=true;

Shape11->Brush->Color=clWhite;

Shape9->Brush->Color=clRed;

Shape12->Brush->Color=clWhite;

Shape10->Brush->Color=clRed;

Shape13->Brush->Color=clWhite;

Shape12->Brush->Color=clRed;

Shape14->Brush->Color=clWhite;

Shape13->Brush->Color=clRed;

Shape15->Brush->Color=clWhite;

Shape14->Brush->Color=clRed;

Shape16->Brush->Color=clWhite;

Shape16->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape17->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

Shape19->Brush->Color=clRed;

Shape19->Brush->Color=clWhite;

Shape20->Brush->Color=clRed;

Shape20->Brush->Color=clWhite;

Shape21->Brush->Color=clRed;

Shape21->Brush->Color=clWhite;

Label17->Caption="SWITCH 3 ON";

Shape22->Brush->Color=clWhite;

Label18->Caption="SWITCH 3 ON";

Label17->Caption="";

Label18->Caption="";

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

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

void __fastcall TForm1::Button12Click(TObject


*Sender)

void __fastcall TForm1::Button5Click(TObject


*Sender)

Shape4->Brush->Color=clRed;

Label12->Caption="OFF";

Application->MessageBoxA("USER SWITCH ON
CHANNEL 4.ARE YOU

LABSHEET 2
BEE3931 PC INTERFACING
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|
MB_DEFBUTTON1)==IDYES;
Shape5->Brush->Color=clGreen;
Label13->Caption="ON";
Button13->Visible=true;
Shape11->Brush->Color=clRed;
Shape12->Brush->Color=clRed;
Shape10->Brush->Color=clRed;
Shape13->Brush->Color=clRed;
Shape18->Brush->Color=clRed;
Shape17->Brush->Color=clRed;
Shape19->Brush->Color=clRed;
Shape20->Brush->Color=clRed;
Label17->Caption="SWITCH 4 ON";
Label18->Caption="SWITCH 4 ON";
}

Button13->Visible=false;
Shape9->Brush->Color=clWhite;
Shape10->Brush->Color=clWhite;
Shape11->Brush->Color=clWhite;
Shape12->Brush->Color=clWhite;
Shape13->Brush->Color=clWhite;
Shape14->Brush->Color=clWhite;
Shape15->Brush->Color=clWhite;
Shape16->Brush->Color=clWhite;
Shape17->Brush->Color=clWhite;
Shape18->Brush->Color=clWhite;
Shape19->Brush->Color=clWhite;
Shape20->Brush->Color=clWhite;
Shape21->Brush->Color=clWhite;
Shape22->Brush->Color=clWhite;
Label17->Caption="";
Label18->Caption="";

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

void __fastcall TForm1::Button13Click(TObject


*Sender)
{

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

void __fastcall TForm1::Button6Click(TObject


*Sender)
{

Shape5->Brush->Color=clRed;
Label13->Caption="OFF";

11

Application->MessageBoxA("USER SWITCH ON
CHANNEL 5.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|

MB_DEFBUTTON1)==IDYES;

Button14->Visible=false;

Shape6->Brush->Color=clGreen;

Shape9->Brush->Color=clWhite;

Label14->Caption="ON";

Shape10->Brush->Color=clWhite;

Button14->Visible=true;

Shape11->Brush->Color=clWhite;

Shape9->Brush->Color=clRed;

Shape12->Brush->Color=clWhite;

Shape11->Brush->Color=clRed;

Shape13->Brush->Color=clWhite;

Shape12->Brush->Color=clRed;

Shape14->Brush->Color=clWhite;

Shape13->Brush->Color=clRed;

Shape15->Brush->Color=clWhite;

Shape14->Brush->Color=clRed;

Shape16->Brush->Color=clWhite;

Shape16->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape18->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

Shape19->Brush->Color=clRed;

Shape19->Brush->Color=clWhite;

Shape20->Brush->Color=clRed;

Shape20->Brush->Color=clWhite;

Shape21->Brush->Color=clRed;

Shape21->Brush->Color=clWhite;

Label17->Caption="SWITCH 5 ON";

Shape22->Brush->Color=clWhite;

Label18->Caption="SWITCH 5 ON";

Label17->Caption="";

Label18->Caption="";

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

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

void __fastcall TForm1::Button14Click(TObject


*Sender)

void __fastcall TForm1::Button7Click(TObject


*Sender)

Shape6->Brush->Color=clRed;
Label14->Caption="OFF";

LABSHEET 2
BEE3931 PC INTERFACING
//--------------------------------------------------------------------------

{
{
Application->MessageBoxA("USER SWITCH ON
CHANNEL 6.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|
MB_DEFBUTTON1)==IDYES;
Shape7->Brush->Color=clGreen;
Label15->Caption="ON";
Button15->Visible=true;
Shape9->Brush->Color=clRed;
Shape11->Brush->Color=clRed;
Shape12->Brush->Color=clRed;
Shape13->Brush->Color=clRed;
Shape14->Brush->Color=clRed;
Shape15->Brush->Color=clRed;
Shape16->Brush->Color=clRed;
Shape18->Brush->Color=clRed;
Shape19->Brush->Color=clRed;
Shape20->Brush->Color=clRed;
Shape21->Brush->Color=clRed;
Shape22->Brush->Color=clRed;
Label17->Caption="SWITCH 5 ON";
Label18->Caption="SWITCH 5 ON";
}

void __fastcall TForm1::Button15Click(TObject


*Sender)
{
Shape7->Brush->Color=clRed;
Label15->Caption="OFF";
Button15->Visible=false;
Shape9->Brush->Color=clWhite;
Shape10->Brush->Color=clWhite;
Shape11->Brush->Color=clWhite;
Shape12->Brush->Color=clWhite;
Shape13->Brush->Color=clWhite;
Shape14->Brush->Color=clWhite;
Shape15->Brush->Color=clWhite;
Shape16->Brush->Color=clWhite;
Shape17->Brush->Color=clWhite;
Shape18->Brush->Color=clWhite;
Shape19->Brush->Color=clWhite;
Shape20->Brush->Color=clWhite;
Shape21->Brush->Color=clWhite;
Shape22->Brush->Color=clWhite;
Label17->Caption="";
Label18->Caption="";

13

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

void __fastcall TForm1::Button16Click(TObject


*Sender)
{

void __fastcall TForm1::Button8Click(TObject


*Sender)
{
{
Application->MessageBoxA("USER SWITCH ON
CHANNEL 7.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|
MB_DEFBUTTON1)==IDYES;
Shape8->Brush->Color=clGreen;
Label16->Caption="ON";
Button16->Visible=true;
Shape9->Brush->Color=clRed;
Shape10->Brush->Color=clRed;
Shape13->Brush->Color=clRed;
Shape16->Brush->Color=clRed;
Shape17->Brush->Color=clRed;
Shape20->Brush->Color=clRed;
Label17->Caption="SWITCH 5 ON";
Label18->Caption="SWITCH 5 ON";
}
}
//--------------------------------------------------------------------------

Shape8->Brush->Color=clRed;
Label16->Caption="OFF";
Button16->Visible=false;
Shape9->Brush->Color=clWhite;
Shape10->Brush->Color=clWhite;
Shape11->Brush->Color=clWhite;
Shape12->Brush->Color=clWhite;
Shape13->Brush->Color=clWhite;
Shape14->Brush->Color=clWhite;
Shape15->Brush->Color=clWhite;
Shape16->Brush->Color=clWhite;
Shape17->Brush->Color=clWhite;
Shape18->Brush->Color=clWhite;
Shape19->Brush->Color=clWhite;
Shape20->Brush->Color=clWhite;
Shape21->Brush->Color=clWhite;
Shape22->Brush->Color=clWhite;
Label17->Caption="";
Label18->Caption="";
}
//--------------------------------------------------------------------------

LABSHEET 2
BEE3931 PC INTERFACING
Shape21->Brush->Color=clRed;
Shape22->Brush->Color=clRed;
void __fastcall TForm1::Button17Click(TObject
*Sender)
{

Label17->Caption="SWITCH 8 ON";
Label18->Caption="SWITCH 8 ON";
}

Application->MessageBoxA("USER SWITCH ON
CHANNEL 8.ARE YOU
SURE.?","Warning",MB_YESNO|MB_ICONQUE
STION|
MB_DEFBUTTON1)==IDYES;

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

Shape23->Brush->Color=clGreen;

void __fastcall TForm1::Button18Click(TObject


*Sender)

Label20->Caption="ON";

Button18->Visible=true;

Shape23->Brush->Color=clRed;

Shape9->Brush->Color=clRed;
Shape10->Brush->Color=clRed;
Shape11->Brush->Color=clRed;

Label20->Caption="OFF";
Button18->Visible=false;
Shape9->Brush->Color=clWhite;

Shape12->Brush->Color=clRed;

Shape10->Brush->Color=clWhite;

Shape13->Brush->Color=clRed;

Shape11->Brush->Color=clWhite;

Shape14->Brush->Color=clRed;
Shape15->Brush->Color=clRed;
Shape16->Brush->Color=clRed;

Shape12->Brush->Color=clWhite;
Shape13->Brush->Color=clWhite;
Shape14->Brush->Color=clWhite;

Shape17->Brush->Color=clRed;

Shape15->Brush->Color=clWhite;

Shape18->Brush->Color=clRed;

Shape16->Brush->Color=clWhite;

Shape19->Brush->Color=clRed;

Shape17->Brush->Color=clWhite;

Shape20->Brush->Color=clRed;

Shape18->Brush->Color=clWhite;

15

Shape19->Brush->Color=clWhite;
Shape20->Brush->Color=clWhite;
Shape21->Brush->Color=clWhite;
Shape22->Brush->Color=clWhite;
Label17->Caption="";
Label18->Caption="";
}
//--------------------------------------------------------------------------

Das könnte Ihnen auch gefallen