Output to the parallel port can be accomplished in Visual C++ with the help of the header library conio.h. This library contains a function, _outp, that can write data to a given port. The code below takes an input from the user and writes it to the parallel port.
#include <conio.h>
#include <stdio.h>
int _outp( unsigned short port, int databyte );
// This program accepts an input from the user
// in decimal and outputs that number as an 8-bit
// binary number to the port at 378 hex, usually
// LPT1
int main () {
int inval = 0;
while ( inval < 256) {
printf("Enter a value in decimal (256 to quit)>");
scanf("%d", &inval);
_outp(0x378, inval);
}
_outp(0x378, 0);
return 0;
}
|