•  
  •  

Control electrical appliances using PC

Here is a circuit for using the printer port of a PC, for control application using software and some interface hardware. The interface circuit along with the given software can be used with the printer port of any PC for controlling up to eight equipment .

The interface circuit shown in the figure is drawn for only one device, being controlled by D0 bit at pin 2 of the 25-pin parallel port. Identical circuits for the remaining data bits D1 through D7 (available at pins 3 through 9) have to be similarly wired. The use of opto-coupler ensures complete isolation of the PC from the relay driver circuitry.
Lots of ways to control the hardware can be implemented using software. In C/C++ one can use the outportb(portno,value) function where portno is the parallel port address (usually 378hex for LPT1) and ‘value’ is the data that is to be sent to the port. For a value=0 all the outputs (D0-D7) are off. For value=1 D0 is ON, value=2 D1 is ON, value=4, D2 is ON and so on. eg. If value=29(decimal) = 00011101(binary) ->D0,D2,D3,D4 are ON and the rest are OFF.

Click here for the sample software.
Click here for the source code of the software (in C).

If there are any problems please contact webmaster@electronic-circuits-diagrams.com

Please share & like


Alphasmart Neo Portable Word Processor Full Keyboard Classroom Typewriter+Case picture

Alphasmart Neo Portable Word Processor Full Keyboard Classroom Typewriter+Case

$54.98



EXC AlphaSmart Neo Laptop Word Processor, Batteries, Cable Tested SHIPS FAST picture

EXC AlphaSmart Neo Laptop Word Processor, Batteries, Cable Tested SHIPS FAST

$56.00



ALPHASMART 3000 PORTABLE WORD PROCESSOR IN EXECELLENT CONDITION picture

ALPHASMART 3000 PORTABLE WORD PROCESSOR IN EXECELLENT CONDITION

$42.00



NEO2 AlphaSmart Portable Word Processor w/ USB Printer Cable picture

NEO2 AlphaSmart Portable Word Processor w/ USB Printer Cable

$84.00



The Writer FUSION Keyboard Instructor Word Processor picture

The Writer FUSION Keyboard Instructor Word Processor

$34.99



AlphaSmart NEO Compact/Slim Portable Classroom Word Processor picture

AlphaSmart NEO Compact/Slim Portable Classroom Word Processor

$70.00



NEO 2 BY ALPHASMART/RENAISSANCE LEARNING HANDLED WORD PROCESSOR picture

NEO 2 BY ALPHASMART/RENAISSANCE LEARNING HANDLED WORD PROCESSOR

$69.99



ESP-WROOM-32 ESP32 WIFI Dual-core CPU Development Board 2.4GHz and Bluetooth picture

ESP-WROOM-32 ESP32 WIFI Dual-core CPU Development Board 2.4GHz and Bluetooth

$8.99



VEVOR Commercial Food Processor Vegetable Cheese Cutter w/ 7 Disks, CE Approved picture

VEVOR Commercial Food Processor Vegetable Cheese Cutter w/ 7 Disks, CE Approved

$517.99



Refrigerant Digital Leak Detector with Metal Case - CPU-C picture

Refrigerant Digital Leak Detector with Metal Case - CPU-C

$38.59



  • bagus adiasa

    thanks, It Works :))

  • tetey

    hi
    i am running the code with manGW on windows 8 and am getting error with the ouportb inthe int main() function below it my code and the specific error

    CODE:

    #include
    #include
    #include

    #define PORT 0x378
    extern int x,X;

    void gotoxy(short x, short y);

    main()

    {
    char val=0,key=0;
    char str1[]=”ON “;
    char str2[]=”OFF”;
    char *str;

    printf(“Press the approriate number key to turn on/off devices:nn”);
    printf(“Here Device1 is connected to D0 of parallel port and so onnn”);
    printf(“Press “x” to quitnn”);

    gotoxy(x,X);
    {
    gotoxy(1,8);
    printf(“Device1:OFF Device2:OFF Device3:OFF Device4:OFFn”);
    printf(“Device5:OFF Device6:OFF Device7:OFF Device8:OFF”);

    }

    while(key!=’x’ && key!=’X’)

    {
    gotoxy(x,X);
    {
    gotoxy(1,12);
    printf(“Value in hex sent to the port:”);
    key=getch();
    switch(key){

    case ‘1’:

    gotoxy(9,8);
    val=(val&0x01)?(val&(~0x01)):val|0x01;
    str=(val&0x01)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘2’:

    gotoxy(21,8);
    val=(val&0x02)?(val&(~0x02)):val|0x02;
    str=(val&0x02)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘3’:

    gotoxy(33,8);
    val=(val&0x04)?(val&(~0x04)):val|0x04;
    str=(val&0x04)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘4’:

    gotoxy(45,8);
    val=(val&0x08)?(val&(~0x08)):val|0x08;
    str=(val&0x08)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘5’:

    gotoxy(9,9);
    val=(val&0x10)?(val&(~0x10)):val|0x10;
    str=(val&0x10)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘6’:

    gotoxy(21,9);
    val=(val&0x20)?(val&(~0x20)):val|0x20;
    str=(val&0x20)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘7’:

    gotoxy(33,9);
    val=(val&0x40)?(val&(~0x40)):val|0x40;
    str=(val&0x40)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,val);
    break;

    case ‘8’:
    gotoxy(45,9);
    val=(val&0x80)?(val&(~0x80)):val|0x80;
    str=(val&0x80)?str1:str2;
    printf(“%s”,str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf(“%x”,(unsigned char)val);
    break; }

    }
    }
    }

    THE ERROR:
    In functiion ‘int main()’:
    52:19: error: ‘outportb ‘ was not declared in this scope outportb

    PLEASE ANY HELP…

  • Inzmam Rana

    in which software we are programming to control parallel port ?
    how to use c/c++?