Reading the Games
Port AtoD Lines in MSW Logo 6.4
(NOTE: This feature is only available in Version 6.4 and above.)
![]() (A standard Joystick has variable resistors on Line1 and Line2) |
The <InGamePort
MASK> function carries out an Analogue to Digital (AtoD) conversion based on
the value of a resistance connected across a line at the Games Port. The function
uses a counting 'loop' to carry out the conversion process. The value returned is
proportional to the resistance. (ie a high resistance returns a high value - in general,
the average resistance value should be in the order of 0 to100k ohms) Make sure you have a
resistance across each line being read or the counting loop will take quite a
while to complete. If your system appears to 'hang' for a while it would indicate that
one, or all of the lines you are reading does not have a resistance across it. If you are sure you have
resistances connected and it still 'hangs': |
For further information on the Games Port see:
http://www.southwest.com.au/~jfuller/logotut/games.htm
Displaying the
Values of Each Line
| to games1 ; The general form is: ; make "InValue InGamePort X ; (Where "X" can be 1, 2, 4, or 8) ; SetXY is used to position the values ; across the screen home CS Make "InValue1 InGamePort 1 SetXY -200 0 label :InValue1 Make "InValue2 InGamePort 2 SetXY -100 0 label :InValue2 Make "InValue4 InGamePort 4 SetXY 0 0 label :InValue4 Make "InValue8 ingameport 8 SetXY 100 0 label :InValue8 end |
The interface used in
these examples has three fixed resistances
If your system appears to 'hang' and the readings
come up as "-1" NOTE: On a standard joystick only lines 1 and 2
should be read. |
Presenting the Values Read as a Graph
| to games2 ; In this procedure the value read on 'line1' is displayed ; graphically by using it as the 'vertical' value in SetXY. ; The state of the Games port is read in a loop controlled by the ; value of the variable "count1". The loop ends when count1 ; reaches 400. Count1 is used as the Horizontal value in SetXY. ; InValue8 is divided by 2 to restrict the height of the 'graph'. cs make "count1 0 PU make "InValue1 ingameport 1 SetXY :count1 - 200 :InValue1/2 PD ; The four lines above move the cursor to the starting point of ; the graph. do.until [make "count1 :count1 + 1 ReadGames] [:count1 = 400] endto ReadGames Make "InValue1 ingameport 1 SetXY :count1 - 200 :InValue1/2 wait 10 end NOTE: The names of the variables are of no importance. I have chosen to use "InValue" and "count1" out of past habit. ANY names could be used. |
As the joystick is moved the display produced by the procedure appears as:
|
So What??? How can I use it?
There are two basic approaches:
1. Incorporate Joystick control into your procedues.
2. Connect 'sensors' to the Games port to measure environmental variables such as Light
and Heat.
The second "approach" listed above offers the most
exciting possibilities. You could simply push the legs of a Thermistor (temperature
dependent resistor) or a Light Dependent Resistor (LDR) into the Games Port socket at the
back of the computer and read changes in light, or temperature directly. The photograph
below shows a more elegant approach using an extension cable and an 'interface' with screw
connectors to attach your 'sensors'. A "Joystick Extension Cable" plugs into the
socket and connects to the Games Port at the rear of the computer.

Some of the things you can do ...
1. Record changes in light and temperature as a graph.
2. Save the data to disk to be imported into a spreadsheet for later charting and
analysis.
3. Connect an output interface to control electric fans and motors based on Light, or
Temperature readings.
4. Compare Light and Heat transmission through various materials.
5. Construct your own 'sensors' based on 100k ohm potentiometers.
6. Use MSW Logo in Science experiments.
7. Use a Joystick to control a remote-controlled vehicle.
8. Develop software for the disabled.
9. Make models of Industrial processes.
10. Measure changes in soil moisture content.
11. Measure changes in skin conductivity (A "Lie Detector"?)
12. ....etc, etc.
For further details about measuring Light and Heat see: http://www.southwest.com.au/~jfuller/logotut/logo22.htm
For information on capturing data to disk see: http://www.southwest.com.au/~jfuller/logotut/logo24.htm
For information on using the Games port in Science experiments
download: http://www.southwest.com.au/~jfuller/scikit.zip
Displaying Input as a Graph ...

MSW Logo Screen Shot
In the above screen-shot, buttons have been added
for control and the oputput is displayed on a 'grid'. (I don't claim the code to be
well written. If you decide to write more elegant procedures, please send me a copy.)
Download the MSW Logo
file.