Writing/Reading specific pins on COMx and LPTx ports 
Author Message
 Writing/Reading specific pins on COMx and LPTx ports



Quote:
> Hi everybody,

>         I am in extreme need of a way to control and switch
specific pins on
> either the RS232 or LPT port in my computer.  I want to use
QuickBasic to do
> this.  I already know the INP/OUT commands, and the addresses of my
ports.  If
> you don't know QuickBasic but know the data needed to send to the
port to
> control the pins, that would be helpful too.  I need to be able to
control at
> least 4 high-intensity xenon or strobe lights for a light show.
The lights
> would probably have a high-voltage relay or transistor in them.  I
have two
> reasons for needing this.  One, to make a bunch of cool lighting
effects to
> run while listening to music; two, to create a thunderstorm
simulation for my
> dad who is really into weather (i.e. synchronize light flashes with
a digital
> recording of thunder).

I posted a message a while ago on how to work a motor like that.
Here is what I learnt from all my e-mails:

1.  There are 24 pins on the parallel cable (Printer cable).  ONLY
pin 2-9 will send out data.  Each of them will output roughly 5
volts.  Connect your positive terminal to one of these pins and the
negative to the outer casing of the cable. You can connect it to pin
10-24 but you risk blowing your I/O port.

2.  To send data out through the port you need to understand binary.
this is how it works:

binary has 8 numbers:

1  2  4  8  16  32  64  128

If you want to switch on pin one then you would use the number 1.

1  2  4  8  16  32  64  128
X

If you want to say, switch on pin 4 and 6 then use the number 40
(8+32)

1  2  4  8  16  32  64  128
           X         X

To switch on all pins use 255 and to turn all off use 0.

The programming is very simple.  use INP(&H378) - depending on your
port number to find out which ones are switched on and OUT &H378,
number   where number is the number explained above. So if you wanted
to switch on all of the pins use this command:  OUT &H378, 255

If you are planning to use a voltage higher than 5 then you will need
to add a battery or other power source as I think you stated.  I am
not going to risk this on my own pentium and if any of this crashes
your computer I wont be held responsible.

I hope this will help you.

Benjamin



Mon, 16 Oct 2000 03:00:00 GMT  
 Writing/Reading specific pins on COMx and LPTx ports

Brilliant! This is exactly the reply I wanted from my posting, almost
everything I needed to know. (Except that that format isn't binary,
but I don't know what it is).
Thanks Lots!

All I can think of now is, can I check if the parallel port has been
strobed (Like ON TIMER or ON COM(2), but ON LPT1STROBE)?
Or in a

DO
LOOP UNTIL parallelstrobe

Simon.

Quote:
> I posted a message a while ago on how to work a motor like that.
> Here is what I learnt from all my e-mails:
> binary has 8 numbers:
> 1  2  4  8  16  32  64  128
> To switch on all pins use 255 and to turn all off use 0.
> The programming is very simple.  use INP(&H378) - depending on your
> port number to find out which ones are switched on and OUT &H378,
> number   where number is the number explained above. So if you wanted
> to switch on all of the pins use this command:  OUT &H378, 255
> I hope this will help you.



Mon, 16 Oct 2000 03:00:00 GMT  
 Writing/Reading specific pins on COMx and LPTx ports



Quote:
>Brilliant! This is exactly the reply I wanted from my posting, almost
>everything I needed to know. (Except that that format isn't binary,
>but I don't know what it is).

<snip>

Hi,

  Just being a bit 'picky' here. (No malace intended. <<I>> don't go around
kicking people when they're down like SOME people around here! d;) EVERY file
is BINARY and can be accessed so. SEQs and RANdoms are just subsets.

C'ya,
  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|

     www.basicguru.com/schullian



Tue, 17 Oct 2000 03:00:00 GMT  
 Writing/Reading specific pins on COMx and LPTx ports

Quote:
> Hi,
> Just being a bit 'picky' here. (No malace intended. <<I>> don't go around
> kicking people when they're down like SOME people around here! d;)

EVERY  > file is BINARY and can be accessed so. SEQs and RANdoms are
just subsets.

SEQ's? RANdoms? Que?
Sorry.

Simon.

(but LPT1 isn't a file... ;))



Tue, 17 Oct 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to address and write and read each parallel port pin

2. Q: Write/read to/from LPTx directly?

3. Read status pins on the parallel port

4. Serial I/O from COMx-Port

5. Detecting LPTx-Ports

6. Win-Api-function for operation serial Port (COMx)

7. Read from Specific String and write to Text File

8. read/write to the diferent pins on a com port?

9. Read and Write to Serial Ports?

10. reading and writing to COM ports

11. reading and writing to a port using Visual Basic

12. Read/Write to Com Port at 19200 Baud

 

 
Powered by phpBB® Forum Software