- 1). Set the output of the port in the form:
OUT [port],[number]
Where [port] is the communications port. You can find this information by clicking "Start" and selecting "My Computer." Right-click the device you wish to use, and select "Properties." Use the COM port listed on the device you're programming with QBasic.
When setting the number, each time you send information the previous information is cleared. Therefore, you'll want to reduce the steps so it will keep your information in memory. For example, you can use the following code:
'set port to 10000000
OUT 888, 1
or, you can use:
'set port to 10110000
OUT 888, 11
Set more than one node to the "ON" position (0 is off, 1 is on). - 2). Set the input of the port in this form:
PortNum%=INP(888)
Where "PortNum%" is a variable to set the value of the data line, to keep in memory for future use. - 3). Merge previous codes together to finish a task in QBasic in the following format:
OUT 888, 43
PortNum%=INP(888)
PRINT PortNum%
This piece of code will have the parallel port output the number 43 into the variable "PortNum%," which is then shown on the screen using the print function.
next post