The goal is to perform simple control via the parallel port.
You will finish it in one evening or die laughing.

What were going to do here is combine 3 things:
1)First the software library:
URL:  http://www.logix4u.net/inpout32.htm
Download: inpout32_source_and_bins.zip
Install:   from the zip file, copy inpout32_source_and_bins/binaries/Dll/inpout32.dll  to c:\windows\system  (or c:\winnt\system, or whereever the system directory is on your computer)
2) Dev c++:
URL:  http://www.bloodshed.net/devcpp.html
Download: http://umn.dl.sourceforge.net/sourceforge/dev-cpp/devcpp4.zip
Install: it. My version is 4.9.8 otherwise known at version 5, beta 8
3) The hardware gizmo:
URL: if you insist,  http://eds.dyndns.org:81/Pages/Schematics.html
Assemble: here is the schematic, I'm going to assume you know how to build it.


The resistors should be about 220 to 330 ohms (lets say orange orange brown gold)
And here is a crude photo of the one that I built:



It shouldn't be possable to damage your computer with this, but dont let any of the wires touch, and I don't take responsibility if your computer has a spontanious combustion episode while you happen to be working on this project. That said you don't have to turn your computer off to install this, just plug it in.

There!
    Now all we have to do it tie it all togethor. So:

4)

Start up Dev c++
File, New, Project



click Console Application,
give it a name,
click OK, (dont worry about the C or C++ setting)



find or create a folder to put the project in and click OK,







now, paste in the following code(over the origional code):


/*
DAn Williams
Aug 14 2004
Demo of parallel port access and controll.
uses inpout.dll
Enjoy.
*/
#include <conio.h>
#include <stdio.h>
#include <windows.h>

/* definitions on what port is what base address depends, so use this */
#define LPT1 0x378
#define LPT2 0x278
#define LPT3 0x3BC

/* register offsets */
#define DATA 0
#define STATUS 1
#define CONTROLL 2

#define BASE_ADDRESS LPT1
/* this is the address we use (modify here if you need to) */

typedef short _stdcall (*INP32)(short PortAddress);
typedef void _stdcall (*OUT32)(short PortAddress, short Data);

int main(void) {

short value;

HINSTANCE hLib;
INP32 Inp32;
OUT32 Out32;

/******************** LIBRARY INIT ***********************/

if ((hLib = LoadLibrary("inpout32.dll")) == NULL) {
printf("Unable to load inpout32.dll, did you copy it to the system folder?\n");
return 0;
}

if ((Inp32 = (INP32)GetProcAddress(hLib, "Inp32")) == NULL) {
printf("Unable to establish handle to input function.\n");
return 0;
}

if ((Out32 = (OUT32)GetProcAddress(hLib, "Out32")) == NULL) {
printf("Unable to establish handle to output function.\n");
return 0;
}


/*********************** MAIN CODE **************************/

// Write to the data register
value = 0x55;
printf("Writing 0x%2X to port 0x%X...\n" ,value ,BASE_ADDRESS );
Out32( BASE_ADDRESS , value );

// Read it back
value = Inp32(BASE_ADDRESS);
printf("\n(Reading) Port %04X = %04X\n", BASE_ADDRESS, value);

// Now use a different value
value = 0xAA;
printf("\nWriting 0x%2X to port 0x%X...\n" ,value ,BASE_ADDRESS );
Out32(BASE_ADDRESS, value);

// Read it back
value = Inp32(BASE_ADDRESS);
printf("\n(Reading) Port %04X = %04X\n\n", BASE_ADDRESS, value);

/******************** CLEANUP ******************************/

// GO FREEE LITTLE LIBRARIES!, GO FREEEEE!!!
FreeLibrary(hLib);

// were done.
printf("Press any key to exit.\n");
getch();

return 1;
}



Now click file, save,
DONT SAVE IT IN THE TEMPLATE FOLDER!
I don't know what git made that the default...
anyhow, re-select YOUR project folder and save it in there.




Now, click Execute, Compile.




If all goes well, you get one of these: If not, I have no idea what could have gone wrong.




Now, click Execute, Run



You should have a dos window come up thats like this:



If you don't have an 'any' key on your keyboard, then click the X in the top right to close the program. Some time in the next year we will cover the addition of the 'any' key to your keyboard, we may also make an 'exit' key, as it would made more sense (escape is not close enough)

that about wraps this project up.

ah wait!

you will notice some lights are on on your gizmo
 you use calc (in scientific mode) to convert between binary and hexdecimal....
Do some playing with the 'value' values (try 0x01 0x02 0x04 0x08 0x10 0x20 0x40 and 0x80) then you can start to get a handle on controlling specific lights.

   Have fun!
        Dan