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;
}
}
}