how to send and process data through parallel port using C

Status
Not open for further replies.

riteshranjan007

Newbie level 4
Joined
Oct 8, 2007
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
how to send data to parallel port

I want to know how to read and send data through parallel port of a computer using C language.
 

sending data to parallel port

Check out 'beyondlogic.org' for info on using the parallel port
 

send data to parallel port c++ code

outportb(0x378,A); //send out data through parallel port
//A = any hex value from 0x00 to 0xFF

B=inportb(0x379); //accept data
//B = unsigned char

Added after 3 minutes:

// my sample program

#include<dos.h>
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned char PIN, POUT;
while(getch()!=27){
PIN=inportb(0x379); /* get input from sensors */
switch(PIN){
case 0x00:while(PIN==0x00){
outportb(0x378,0x01); /* forward dc motor */
}
break;
case 0x08:while(PIN==0x08){
sleep(2); /* pause */
outportb(0x378,0x80); /* stepping action - left */
outportb(0x378,0x40);
outportb(0x378,0x20);
outportb(0x378,0x10);
sleep(2);
}
break;
case 0x10:while(PIN==0x10){
sleep(2); /* pause */
outportb(0x378,0x10); /* stepping action - right */
outportb(0x378,0x20);
outportb(0x378,0x40);
outportb(0x378,0x80);
sleep(2);
}
break;
case 0x18:while(PIN==0x18){
outportb(0x378,0x02); /* reverse dc motor */
}
break;
default:
outportb(0x378,0x00); /* no action */
break;
}
}
}
 

how to send thru parallel port

Have you tested this code? In the while loop it should be the port that is read continuously instead of the variable PIN.
 

how i can send data through parallel port

This will not work in WinXP, Vista, only in DOS.
 

outportb 3f8

hey

you want to make interfacing the computer with a microcontroller with C / C++ ?

it's easy if you know two codes , this codes are :-

1- inp = input port (1-byte) , inpw = input word (2-bytes) .

2- outp = output port (1-byte) , outw = output word (2-bytes) .

- you must know your parallel port number in your computer which is usually

LPT Nu. : 3F8

The following code is a prototype for making interfacing in C++ :

#include <stdio.h>
#include <conio.h>
#include <dos.h>

int main(void)
{
unsigned result;
unsigned port = 1570 ; //the number of parallel port in octal system .
result = inpw(port);
printf(" Word read from port %d = 0x%X\n", port, result);
return 0;
}

try it and enjoy , if there is a problem tell me .
 

Re: help me for send and receive data on LPT port

Dear boss
Thank you
I need a program in C++ language that can send and receive data or chat between two computer through LPT port
please give me source code from sender and receiver for compile and create exe file
I think a program in your site in part "how i can send data through parallel port" is just checking port program with C++ but i need a program can send and receive data through LPT port.
Please help me
My Email Address is : bahram4447@yahoo.com & bs.classic@Gmail.com if need for your respond

best regard.
bahram sabahi far
 

i need a c file to turn off the leds connected with paralell port using turbo c
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…