computer interfacing tutorial-printer, serial, game, usb port
 

6.2.2. Measuring Variable Resistance - Game Port

This program shows you how to read the joysticks position. The main function is only used to display the joysticks position. In this experiment we used only simulate 1 joysticks position, these joystick connected to pin 3 as shown in the picture bellow.

Delphi Programming ( Download File exp622.zip )

a.To read the button position, first you should prepare a form with 1 timer, 1 edit and labels component, as shown in the picture bellow. In timer1 component in object inspector, set up for the configuration as shown in the picture bellow.

 

             

b. Click twice on timer 1, and then insert instruction as shown bellow

procedure TForm1.Timer1Timer(Sender: TObject);
var data:byte;i:integer;
begin
timer1.enabled:=false;
i:=0;
repeat
asm
mov dx,$201
mov al,0
out dx,al {write any value to $201}
mov dx,$201
in al,dx {gets data from $201}
mov data,al
and data,$1
end;
i:=i+1;
until data=0;
edit1.text:=inttostr(i);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
 timer1.enabled:=true;
end;

c. To run the program, you must hit F9 or RUN from main menu, then you will see a picture as shown bellow. Try to simulate the program by turning righ or left the potensio in the circuit.

PREVIOUS

 

Free Software
Delphi

Lesson 1
Delphi Programming
1.1. IDE Delphi
1.2. Component


Lesson 2
Printer Port
/ LPT
1.1.Basic
1.2.Address
1.3.Port Register
1.4.8 Bit Data Input
1.5.Test Circuitry
1.6.Assignment

Lesson 3
Printer Port / LPT
Experiments

3.1.LED
3.2.Swicht
3.3.Motor Stepper
3.4.DAC
3.5.ADC
3.6.Graph Display

Lesson 4
Serial Port

4.1.Basic
4.2.Hardware
4.3.Port Register

Lesson 5
Serial Port Experiments

5.1.LED
5.2.Stepper Motor
5.3.Swicht
5.4.ADC

Lesson 6
Game Port
Joy Stick
6.1. Basic
6.2. Experiments