CONTROLING 230V LIGHT BULB USING COMPUTER (PARALLEL PORT)

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

bc547 data sheet

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 

clip_image012
clip_image014
clip_image016

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

clip_image002[15]
clip_image018
clip_image020

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

clip_image022
clip_image002[11]

check this video to see how it works



Source code

#include <windows.h>

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
Download the Source Code and Driver file here

BUY GOODS ONLINE AND SHIP TO GHANA
CONTROLING 230V LIGHT BULB USING COMPUTER (PARALLEL PORT) CONTROLING 230V LIGHT BULB USING COMPUTER (PARALLEL PORT) Reviewed by Zakaria Mohammed on August 23, 2015 Rating: 5

No comments :

Powered by Blogger.