Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer port as analog switch (all on/all off) io 1

Status
Not open for further replies.

qb101

Programmer
Apr 12, 2001
1
US
Hello,

How would I go about turning all of the pins on my printer port on at the same time? I need to use it as an analog switch. I am adapting a program to interface with some lab equipment usind an A/D converter. Essentially, I need to make the port come on and stay on until the program cyles.

Thank You

qb101
qb101@oscartrapp.com
 
'The following code will allow you to toggle the pins on LPT1:

A% = 0
OUT &H378, &H0
PRINT "Press `X' to quit"
start: A$ = INKEY$
IF A$ = "" THEN GOTO start
IF A$ = "1" THEN A% = A% XOR &H1
IF A$ = "2" THEN A% = A% XOR &H2
IF A$ = "3" THEN A% = A% XOR &H4
IF A$ = "4" THEN A% = A% XOR &H8
IF A$ = "5" THEN A% = A% XOR &H10
IF A$ = "6" THEN A% = A% XOR &H20
IF A$ = "7" THEN A% = A% XOR &H40
IF A$ = "8" THEN A% = A% XOR &H80
IF A$ = "X" OR A$ = "x" THEN END
OUT &H378, A%
GOTO start




Kim_Christensen@telus.net
 
By the way, that code could be rewritten as follows:
[tt]
value% = 0
DO
OUT
&H378, value%
a$ = INPUT$(1)
value% = value% XOR (2 ^ (VAL(a$) - 1))
LOOP UNTIL LCASE$(a$) = "x"
[/tt]

Much more compact :) Though admittedly less readable to the unaccustomed reader.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top