Do you want to sit in front of your computer and control Your Appliances like the 230V light bulb then here is a simple project
If you are new please visit How to program the Parallel port in windows to learn the basics.

Set up the circuit as shown below

Note in the picture that the base of the transistor is connected to data port 2 (D1) so we will send out(address,0x01). You can also connect it either 2 to 9 check How to program the Parallel Port for more information on this

#### Calculations

How to calculate the base resistor R1

Relay resistance measured was 89.2 â„¦
Let Vin be the Parallel port voltage when it is ON
From the Collector-Emitter loop

Calculating IB from IC

Now from the Base-Emitter loop, the Base resistor (R1) can be calculated as

My Vin measured from the parallel when it is high was 3.34V so it will be

### Source code

 #include using namespace std; typedef short _stdcall (*inpfuncPtr)(short portaddr); typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum); int main() {     HINSTANCE hLib;     inpfuncPtr in;     oupfuncPtr out; hLib = LoadLibrary("inpout32.dll"); if (hLib == NULL) { cout<<"LoadLibrary Failed.\n"; cin.get(); return -1; } in = (inpfuncPtr) GetProcAddress(hLib, "Inp32"); if (in == NULL) { cout<<"GetProcAddress for Inp32 Failed.\n"; cin.get(); return -1; } out = (oupfuncPtr) GetProcAddress(hLib, "Out32"); if (out == NULL) { cout<<"GetProcAddress for Oup32 Failed.\n"; cin.get(); return -1; } string input; do { cout<<"\n type 'on' or 'off' to switch the bulb.(0 to quit) \n"; cout<<"Input: "; cin>>input; if (input=="on" || input=="ON") {     out(0x378,0x01);   //turn data port 2 high     cout<<"Light is ON\n"; } else if(input=="off" || input=="OFF") {     out(0x378,0);   //send 0 to data port pin     cout<<"Light is OFF\n"; } } while (input != "exit" || input !="EXIT"); return 0; }
Remember to include the driver in your project directory