Robot os. The infinite loop.
' set or reset values
' input sensor values
' Other jobs
' Do what is needed based on input values.
Part I. Set or reset values.
Part II Get sensor values.
Reading the Input pinsThe command to read from ports in qbasic is INP. The address you need to read from is the address of the parallel port (usually 378h) + 1; so the usual address is 379h. As i mentioned before, the pins used for input are 10-13 and 15. Reading the different pins is little harder than writing to the ports, as you have to mask out the pins your not interested in. When you read the port, the first 3 bits returned are not used. For example, the qbasic code below would read pin 12 (out of paper). When this port is high, "Out of paper / pin 12 toggled" will be displayed:
data = inp(&h379) IF (data and 32) = 32 then print "Out of paper / pin 12 high"The table below list the pin input pin number, its normal purpose, and the number required to read it (eg 32 was used in the above example):
|Pin Number||Normal Purpose||Number to read|
|11||High when not Busy||128|
|12||High when out of paper||32|
|13||High when printer online||16|
|15||High when no error||8|
If you understand binary, you should immediately see where these numbers are coming from, and why they are used to mask out all of the other pins we aren't trying to read. The simplest thing you can use to test this is to just connect a switch between an input pin and a ground pin (18-25). For example, if you connect a switch between pins 15 and 20, you could use the following code to monitor when the switch is pushed:
start: res = INP(&H379) CLS IF (res AND 8) = 8 THEN PRINT "Button pushed" ELSE PRINT "Button NOT pushed" FOR delay = 1 TO 500: NEXT delay GOTO startI know this code is a little messy, and will flicker, but it's written for clarity. The same code can be used to monitor the other four input lines by changing to the '8' to another number from the table.
Part III Other jobs.
We can use programs such as parcon to set values at the parallel port for such jpbs as controlling the power train. see also: https://www.instructables.com/id/Mini-parallel-port-break-out-cable/