CrazyEngineers
  • Tutorial: Parallel Port Interfacing Techniques - Part 2

    PC Parallel Port Interfacing Techniques - Part 2

    16 October 2006 v1.0
    Elec: 3.5 Comp: 2 Mech: 0​

    Introduction


    In this tutorial we will flash a LED (Light Emitting Diode) connected to your printer port socket. Reading the #-Link-Snipped-# is recommended to get a general idea what you are upto.

    Connections


    To connect a LED to your port first you have to know what it looks like. Here are the two most common connectors that you can have.

    D-Type 25 Pin connector


    [​IMG]

    Pin Layout:

    [​IMG]

    36 Pin Parallel Centronics


    [​IMG]

    Pin Layout:

    [​IMG]



    The LED


    Shown below is a very common LED found anywhere from toys to computers. To connect, insert the positive pin into Pin number 2 of your port. And the negative to any ground of your connector. Pin 19 is an easy reach.

    [​IMG]


    In the above image the longer pin is positive and the shorter one is negative (ground). If you have a LED looking like the left one then you have to find out yourself which one is +/- by connecting it to a battery. I would recommend a 220ohm or 470ohm resistor in series with the LED. Mine worked without the resistor but I cannot promise anyone!

    Ok after you finish this setup, it is now time to test the light! See if you have really found out the correct address by following the #-Link-Snipped-# then download #-Link-Snipped-#( #-Link-Snipped-#)** to have real-time control over your Port to test the light.

    [​IMG][​IMG]

    Open the executable; you should see a blue screen with port addresses, pins and their description. Choose the address where you have connected the port wire, and click on PIN 2 (Data 0) (there should be a cross on it now). Look at the LED, it must glow. If it does not glow then try different Port addresses, LPT1, LPT2 etc.

    Programming the Parallel Port in C, C++, VB or Java with ‘Windows the great XP’ is not easy since it does not allow you to access the Ports directly. All hardware is virtualised. I somehow have a feeling programming in VB is easier. Very basic LED flashing is also easy through Assembly Language. I’ll look into this problem and post a tutorial soon.

    Dont hesitate, ask me if you have trouble with anything!!! Writing a tutorial from scratch is not easy so please don’t mind random grammar mistakes 😀


    Some Useful links:

    Parallel port output : A very detailed look into the Port basics and programming.

    #-Link-Snipped-# : Excellent for explanation on Win NT/XP programming.

    #-Link-Snipped-# : The Debug program to test your parallel port with LED
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorOct 16, 2006

    Great going, xHx ! [​IMG]

    We plan to make pdfs of the articles posted on CE forums and make them available for download* along with the poster's name/id & contact. How about coming up with your own diagrams?

    -The Big K-
    p.s: * You can already guess we have many things planned along with the forum restructure 😉 . Keep doing a good job, buddy!
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberOct 16, 2006

    Hay thanks biggie. I too am waiting for the upgrades and some attachment ability (if you all think its necessary). In this perticular tutorial, I took the working pics in the bottom, the remaining are from the linked sites, and since this was a very simple one it did not need any major schematics. I will be writing a tutorial to program in some languge for more flexability, there I will be clear on the diagrams and pictures.

    I want ot see people get interested by reading this tutorial, and I hope I did that. If there can be any changes to improve it, anyones views are welcome! 😁


    This is just the begining, we can in a year come up with a full home automation tutorial and project 😛

    Thanks a lot again! 😀
    Have fun.
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorOct 16, 2006

    No promises for the attachment ability. The simpler way is to create an id on <a href="https://www.flickr.com" target="_blank" rel="noopener noreferrer">Find your inspiration. | Flickr</a> ( a Yahoo! Company ) and link the images. Let the Flickr guys do the image hosting job 😉

    This is just the begining, we can in a year come up with a full home automation tutorial and project 😛
    Of course! To speed up the process, our editor-in-chief & I had chat with professors from Engineering colleges & they seemed to be excited about us. Probably we'll see better stuff in coming days.

    Good initiative, xHx! Very soon, we will try to have a separate place for all the good articles 😀

    -The Big K-
    Are you sure? This action cannot be undone.
    Cancel
  • desijays

    MemberApr 16, 2007

    i hope you guys don't mind me digging up this post from under the grave, but i was just going throught it and kinda got curious.

    xheavenly, would it be possible for you to make a brief post about USB interfacing if you have time. Just the basics!!. Just like your posts about parallel port interfacing would be good.

    And probably turning on and off an LED using the USB port if thats possible 😉

    and few other things...

    is there any difference between RS232, the parallel port and the serial port?
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberApr 20, 2007

    desijays
    xheavenly, would it be possible for you to make a brief post about USB interfacing if you have time. Just the basics!!. Just like your posts about parallel port interfacing would be good.

    And probably turning on and off an LED using the USB port if thats possible 😉

    and few other things...

    is there any difference between RS232, the parallel port and the serial port?
    1. Well USB is a bit difficult than parallel or serial port. And moreover I have never worked with USB. Their programming in windows is shrouded with crappy permition protocols and timing stuff. wind00z XP/Vista is really the worst OS you can possibly use for programing hardware. Its all virtualised.

    Take a look at #-Link-Snipped-#

    2.
    • Well, there are many differences but technically parallel is parallel communication. That is, at the same time you can have more than one output/input working. Usually there are 8 inps and 8 outps depending on your BIOS settings and hardware. They are:
    • #-Link-Snipped-#
    • #-Link-Snipped-#
    • [SIZE=-1]#-Link-Snipped-#[/SIZE]
    [SIZE=-1]
    [/SIZE]
    • RS-232 IS serial port. It has serial communication. That is, one bit after the other in a single wire. It has a longer range too, meaning long wires will not spoil the data. Check this page for [SIZE=-1]#-Link-Snipped-#[/SIZE]
    • The USB is a whole other story. Here is line from Beyondlogic.org.
    • " Starting out new with USB can be quite daunting. With the #-Link-Snipped-# at 650 pages one could easily be put off just by the sheer size of the standard. This is only the beginning of a long list of associated standards for USB. There are #-Link-Snipped-# such as the HID Class Specification which details the common operation of devices (keyboards, mice etc) falling under the HID (Human Interface Devices) Class - only another 97 pages. If you are designing a USB Host, then you have three Host Controller Interface Standards to choose from. None of these are detailed in the USB 2.0 Spec."
    • Anyway, if you really want to interface a USB device 😀 then have a look at the whole tutorial here [SIZE=-1]#-Link-Snipped-#[/SIZE]
    Good luck! Its really fun though😀
    Are you sure? This action cannot be undone.
    Cancel
  • desijays

    MemberApr 25, 2007

    Link galore. 😀 Thanks for the links mate. I'll look into it.

    Hopefully I should get something going 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Ashraf HZ

    MemberSep 12, 2007

    Oh, I should have posted here instead of Part 1 of the tutorial 😛 great work xheavenlyx. Wanted to ask a few things:
    • Is it safe to use the parallel port on a laptop for experiments? eg, lighting LED's.
    • Can you give a sample C code on how to light an LED on and off? Like what libraries to use. At least I know it involves a while loop and a delay 😛 I believe you have to use this file called Inpout32.dll, am I right?
    • Can you also recommend me a program to use for Assembly Language programming?
    Thanks a lot dude!
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberSep 13, 2007

    1. No its not really safe to directly use a parallel port of a laptop. You CAN try an LED or something, because the grounds can sink that much current from your port. However, dont try using motors directly. The links I have provided are VERY useful and have many circuits too. Read carefully. I cant cover that here, since everyone has their own design.

    2. god, forgive me, I actually stoped programming PP in newer PC because of that problem (Windooz..input32.dll) but if you search you will get a LOT of info. As for the libraries, not many are needed. In win98 it were stdio.h and io.h or something. Very few. Here is a sample code I wrote 4 years ago (!):

    //This example code shows how to switch a LED on/off in Visual C++.
    //We use two variables N and L explained below.
    
    //I am assuming you have some knowledge in C++. Instruction to connect the LED is given in the Tutorial.
    
    
    
    
    
    
    
    #include <iostream.h>  //The most important include to display data on screen.
    #include <conio.h>     //Include for outp and inp functions for the printer port.
    #include <windows.h>   //For _sleep functions for our time delay.
    
    #define addr 0x3BC     //IMPORTANT: Normaly 378 is the most common address, 
                           //if not then insert your address instead of 378
    
    int main()
    {
        int freq; //Variable for time delay.
        int L; //Variable for counts of Blinking LED.
        
        
        cout<<"\t\t XheavenlyX WELCOMES YOU!!! \n\n";         //How can I forget this ^_^
        
        cout<<"How many times to blink?? Enter 0 to exit: ";  //Ask user how many times to blink the LED
        cin>>L;                                               //And exit if zero is entered.  
        
        
        if (L==0)
        {
            cout<<endl<<"Exiting application..."<<endl;             //Code to exit if L = 0. 
            for (int i=0;i<=5;i++) {_sleep(500);}                   //A lame pause before exit!
            exit(0);
        }
    
        cout<<"Frequency (in mS): ";                          //Ask user to enter the frequency at which the LED will blink.
        cin>>freq;                                              //Store that value in freq.
        
    //Bottom code is the Juice! This will blink your LED the number of times you put in L.
    //The speed of blinks will depend on freq. As an example if you entered 500milliseconds. The LED
    //will blink twice every second since 500ms is half of 1000ms (1000millisecondss = 1sec)
    
        for (int i=1;i<=L;i++)        //The loop. L times to blink.
        {
        _outp(addr,1);             //Output is high in the first 'Data bit' of port(*), i.e Pin number 2 where you have connected the LED.
        _sleep(freq);               //freq mS delay between the high and low of LED.
        _outp(addr,0);             //Output is low now
        _sleep(freq);               //Pause again between the high,
        }
        return 0;                   //main returns nothing to you. ^_^
    }                               // For an indepth look at 
    
    
    //(*)NOTE: There are some simple calculations to turn on/off the other PINs on the printer port.
    
    //links
    // https://msdn2.microsoft.com/en-us/library/733szwah.aspx _outp, _inp etc.
    How input32.dll works:
    #-Link-Snipped-#

    3. Assembly learning is somewhat a smooth ride if you stick with it. And it can be very very helpful. Speacially if you are planning on optimizing complex control instructions. It can be for Microcontrollers or your PP programming. That too, youll have to search...😀
    Are you sure? This action cannot be undone.
    Cancel
  • Ashraf HZ

    MemberSep 13, 2007

    Cool, thanks a lot bro! Really appreciate it 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Abyss

    MemberSep 23, 2007

    Hi..good day
    I would like to say thank you for posting those stuffs about parallel ports. It helped me a lot. I am very much interested with that tutorial. Thank God there are people like you. As for now, i want to make a project using LEDs to connect in parallel port. The LEDs should turn off/on upon user input. The whole thing is to be controlled by an Assembly language program or a C++ program that has an inline funtions of Assembly language. The problem is, I got very little Knowledge in assembly language. From your tutorial,i already leared how to connect the LEDs in the parallel port. Thanks to you. I hope you can help me.

    Aside from LEDs, i was also pkanning to use the stepper motor. Same thing will happen,it will be connected thru the Pport. Even a single or continous rotation operation of the motor may do. Still an Assembly language program is needed here.

    I am looking forward for your reply.

    I am Carlo Moratalla.
    My email: #-Link-Snipped-#

    Thaks a lot.
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberSep 24, 2007

    Thank you for telling me that this page was really important to you! and hope to help in anyway can.

    Firstly, I have to confess that I haven't tested PP interfacing on new OS! Like Wondows XP and Vista. Thats because in these new OS, windows does now allow direct hardware access. You have to access it through another dll, read the above posts. And my laptop has no ParallelPort! Now there are 2 things you can do.

    1. go to these sites I have given above and here. and try to implement it in XP. When I get time to do this, Ill surely let you know. And if you have an old pc with windows 98 then better.

    2. I can give you the schematica of interfacing a motor, or stepper motor. And an idea of the algorithm, but remember you have to implement it yourself on your PC so, the only way to learn it is thru experimentation.

    Remember, I cannot explain all the electroncis and programming involved, its impossible. So here is some start:

    ---NEXT POST---
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberSep 24, 2007

    #-Link-Snipped-##-Link-Snipped-#

    The above image shows how to interface a relay. 12V relay is good since this relay which in turn will control the switch of a simple DC motor. The diodes are very important, so as to reduce the voltage spike moving into your PP and destroying it.

    Now dear bro, for stepper motor you have to research yourself. Presently I am on a college project so I have no time to do that. Go further in your project and tell me how its going and what you have done!! Thats the most important part. So try whatever you have learnt and tell us about it.

    By the way @ash, can you tell me if you have tried interfacing on XP and what were the results, please try to do so this week if you can, it will be really helpful.
    Are you sure? This action cannot be undone.
    Cancel
  • Ashraf HZ

    MemberSep 24, 2007

    Ah, I haven't tried yet, was also busy with projects. But I'll try by the end of this week hopefully! My roommates had interfaced with it on a desktop PC with Windows XP, lighting up a mini traffic light system. I'll get them to teach me a bit.
    Are you sure? This action cannot be undone.
    Cancel
  • sgrshukla

    MemberSep 28, 2007

    @ abyss and @ heavenly..
    Hello friends, i am also looking to run a stepper motor using the parallel port.. i have bit idea of stepper motor operation . i am also finding difficulties in outout on parallel port as i am having winXP .. can win98 solve this problem??? and what to do if i want to run the same program in winXP???

    mail: sgrshukla@gmail.com
    Are you sure? This action cannot be undone.
    Cancel
  • sgrshukla

    MemberSep 28, 2007

    @ abyss and @ xheavenlyx..
    Hello friends, i am also looking to run a stepper motor using the parallel port.. i have bit idea of stepper motor operation . i am also finding difficulties in outout on parallel port as i am having winXP .. can win98 solve this problem??? and what to do if i want to run the same program in winXP???

    mail: sgrshukla@gmail.com
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberSep 29, 2007

    Listen very carefully here:

    Do everything I have given above in the tutorial plus the following posts and experiment. Then tell us what you have done and what were the results and how you have tried it, what was your code in which language, and what was your circuit? everything like this.

    THEN you can post your problem here, and we will try our best to ans you.

    And yes win98 is easier to program then XP. (How its done is given above somewhere)
    Are you sure? This action cannot be undone.
    Cancel
  • Abyss

    MemberOct 7, 2007

    Hi every..I have done LEd and Motor controlling thru the parallel port..Mine work even in WindowsXP..
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberOct 7, 2007

    Mere bhai, please can you help the people here and me and tell how you did it??

    Some circuit diagram, and explaination, something!!@!!
    Are you sure? This action cannot be undone.
    Cancel
  • Abyss

    MemberOct 15, 2007

    INTRODUCTION

    Computer programming was one of the great advancement in technology. It contributed a lot to help humanity. Most electronic devices that we use today are endowed with programming.

    Implementation of computer programs with hardware is quite an arduous task. The computer program comes in various languages. The proper programming language must be noted. Furthermore, the bus line should be appropriate in order for the hardware to run effectively. Hence, the language to use should be relative with the bus line.

    Assembly language program was found to be the outstanding language when it comes to hardware programming. It provides an easy data communication between the program and the hardware. It shows an actual data representation which can be use to drive the hardware.

    In harmony, the parallel port was one of the suitable line of communication between the program and hardware. As a bus line, it allows a direct link amid the instruction set and the data output.

    In this project, I introduce the PC Parallel Port and how to identify its address for use in home electronic projects. An assembly language program was used to drive the hardware. The hardware deals with LEDs (Light Emitting Diode). It includes simple LEDs and a Seven-segment Display. The program contains instruction that can turn the LEDs ON and OFF. The program also receives values that will be use to drive the seven-segment display. The program uses an A86 macro assembler, D86 debugger V4.04.

    By implementing this project, one can have a better understanding about Hardware Programming.




    MATERIALS


    1 Breadboard
    1 Printer Cable (DB-25)
    8 Light Emitting Diodes
    1 Seven-segment Display
    Connecting wires


    CONCEPTS INVOLVED

    The Parallel Port

    The Parallel Port is the most commonly used port for interfacing home made projects. This port will allow the input of up to 9 bits or the output of 12 bits at any one given time, thus requiring minimal external circuitry to implement many simpler tasks. The port is composed of 4 control lines, 5 status lines and 8 data lines. It's found commonly on the back of your PC as a D-Type 25 Pin female connector. There may also be a D-Type 25 pin male connector.

    The lines in DB25 connector are divided in to three groups, they are:
    • Data lines
    • Control lines
    • Status lines

    As the name refers, data is transferred over data lines, Control lines are used to control the peripheral and of course, the peripheral returns status signals back computer through Status lines. These lines are connected to Data, Control and Status registers internally. The details of parallel port signal lines are given in Figure1.

    #-Link-Snipped-#

    Fig 1: The Parallel Port




    Table 1. Pin Assignments of the D-Type 25 pin Parallel Port Connector.
    Pin No D-Type 25
    Signal Name
    Direction
    Register
    1
    nStrobe
    In/Out
    Control1
    2
    Data 0
    Out
    Data1
    3
    Data 1
    Out
    Data2
    4
    Data 2
    Out
    Data3
    5
    Data 3
    Out
    Data4
    6
    Data 4
    Out
    Data5
    7
    Data 5
    Out
    Data6
    8
    Data 6
    Out
    Data7
    9
    Data 7
    Out
    Data8
    10
    nAck
    In
    Status1
    11
    Busy
    In
    Status2
    12
    Paper-Out / Paper-End
    In
    Status3
    13
    Select
    In
    Status4
    14
    nAuto-Linefeed
    In/Out
    Control2
    15
    nError / nFault
    In
    Status4
    16
    nInitialize
    In/Out
    Control1
    17
    nSelect-Printer
    In/Out
    Control2
    18 - 25
    Ground
    Gnd


    Port Addresses

    The Parallel Port has three commonly used base addresses. These are listed in table 2, below. The 3BCh base address was originally introduced used for Parallel Ports on early Video Cards. This address then disappeared for a while, when Parallel Ports were later removed from Video Cards. They has now reappeared as an option for Parallel Ports integrated onto motherboards, upon which their configuration can be changed using BIOS.
    LPT1 is normally assigned base address 378h, while LPT2 is assigned 278h. However this may not always be the case as explained later. 378h & 278h have always been commonly used for Parallel Ports. The lower case h denotes that it is in hexadecimal. These addresses may change from machine to machine.

    Address
    Notes:
    3BCh - 3BFh
    Used for Parallel Ports which were incorporated on to Video Cards
    378h - 37Fh
    Usual Address For LPT 1
    278h - 27Fh
    Usual Address For LPT 2


    Accessing Ports: Writing to the Port
    To write to the eight data registers we can pass a value of 0 - 255 at the parallel port address. In Binary every bit of that number controls one or more output bit. Table 4 illustrates them.
    DB25-Pin
    2
    3
    4
    5
    6
    7
    8
    9
    Data Pin
    0
    1
    2
    3
    4
    5
    6
    7
    Value
    1
    2
    4
    8
    16
    32
    64
    128

    Table 3: Data Pins Value
    For example to set pins 2 and 3 to logic 1 then output value would be: 1+2=3. Similarly to set on pins 3, 5 and 6 then output value would be: 2+8+16=26. In this way value for any bit combination can be calculated. Also it should be noted that:
    Value
    Description
    0
    Set all data Pins to logic level Zero
    255
    Set all data Pins to logic level One

    Table 4: Particular Value


    Schematic Diagram






    The Program Code

    The following Assemble Code writes 255b to the port using Assembly’s OUT mnemonic. The OUT accepts 2 operands: DX and AL. it writes the data from the AL (Accumulator Register) to the port Address stored in DX (Data Register).

    MOV DX,03BcH ;Port AddressMOV AL,255 ;Data: All LEDs onOUT DX,ALINT 21H


    A86 macro assembler, D86 debugger V4.04

    A86 (with its 32-bit version A386) is the finest assembler available, at any cost under any terms, for the Intel 86-family of microprocessors (IBM-PC, compatibles, and not-so-compatibles).
    A86 accepts assembly language source files, and transforms them directly into either: (1) .COM files executable under DOS (or in a DOS box under Windows), starting at offset 0100 within a code segment; (2) .OBJ files suitable for feeding to a linker to create EXE files; or (3) object files starting at offset 0, suitable for copying to ROMs. A86 is a full featured, professional-quality program. I designed A86 to be as closely compatible to the standard Intel/IBM assembly language as possible, given that I insisted upon making design and language enhancements necessary to make A86 the best possible assembler.
    D86 (with its 32-bit version D386) is a screen-oriented program that allows you to troubleshoot faulty computer programs written to run under DOS (or in a DOS box under Windows). It "freezes" the state of your program, and allows you to investigate the values of registers, flags, and memory. You can monitor your program's execution by stepping it one instruction or procedure at a time; or you can start your program running, telling D86 to stop it when it reaches certain locations. D86 recognizes the symbol-table output of the A86 assembler, creating a symbolic disassembly of your A86 program, and allowing you to refer to locations and variables by name.
    OPERATION

    T Assemble the Hardware to the breadboard and connect the circuit to the designated data pins.
    T Plug the Printer cable to the parallel port.
    T Make sure that the Assembler is in the location: C:\ASM
    T Run the CMD.exe.

    T On the cmd, type in cd\. Then press enter. Next, type in cd asm then press enter.

    T Assemble the file 255.asm, off.asm, LED.asm and segment.asm respectively. Use these syntax:
    asm LED.asm
    T Run each program by just typing the filename.
    T Use the table 4 for desired outputs.
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberOct 15, 2007

    Thanks a lot for this dude! Much appreciated.

    But I thing there is problem, even debug or assembly compilers do not work easily in XP and Vista, direct hardware access is not allowed. And if this is taken from some website then dont forget to post the actual website address, since some diagrams are missing, and I want to go through them.
    Are you sure? This action cannot be undone.
    Cancel
  • Smint

    MemberNov 23, 2008

    Thanks to xHx for all this information.

    I'm just getting interested in programming for the parallel port.

    Actually I have a current project where I need some simple digital IO from a PC.

    My question is if it would be possible to use the parallel port for continous input and output at the same time.

    Example:
    1: Some program state tells me I need an automatic door to be opened.
    2: I'll set a one bit output to be high so I trigger a switch for the door.
    3: This switch is connected to a set of sensors determining if it's ok to open door. There are some security issues.
    4: If it is not ok a light at the door will show that manual actions need to be done to allow the door to be opened.
    5: When it's ok a switch will send a input to the parallel port and the program will do some task that depends on the door beeing open.

    So what i need is 1 bit output saying that i need the door to be opened and a 1 bit input to tell me if the door is open. But these has to be simultaniously available.

    The cable will be short as the switches for both input and output will be placed next to the PC and the long wires will go from the switch to door circuits.

    Can this be done with the parallel port or do i need to invest in a digital 16 channel PCI I/O board? (seems thats the minimum number of IO's on that sort of cards on the market.)

    I would really like to be able to just use the parallel port as to not impose anything vendor specific on the project.
    Are you sure? This action cannot be undone.
    Cancel
  • Munguti

    MemberJan 8, 2009

    I found a turorial on the parallel port. It had the following include files which refused to work in my visual studio 98.
    dos.h problem with this is that it was claimed in the turtorial to have outportb function and delay both of which were absent.
    _defs.hwhich was non existent and also hed problems with some of its code. they generated alot of errors.
    i obtained both the header files in the net. they had alot of issues. anyone know what the problem is??????????
    the actual tutorial broke the 20000 words limit and i couldn,t post it however here is a sample of one of the programs it had.

    D. Simple Example

    Refer to the figure titled Figure #3 - Typical Application showing a normally open push button switch being read on the BUSY input (Status Port, Bit 7) and an LED which is controlled by Bit 0 on the Data Port. A C language program which causes the LED to flash when the push-button is depressed appears below. Note that an output logic zero causes the LED to light.


    /* File LED_FLSH.C
    **
    ** Illustrates simple use of printer port. When switch is
    ** depressed LED flashes. When switch is not depressed, LED is
    ** turned off.
    **
    ** P.H. Anderson, Dec 25, '95
    */

    #include <stdio.h>
    #include <dos.h> /* required for delay function */

    #define DATA 0x03bc
    #define STATUS DATA+1
    #define CONTROL DATA+2

    void main(void)
    {
    int in;
    while(1)
    {
    in = inportb(STATUS);
    if (((in^0x80)&0x80)==0)
    /* if BUSY bit is at 0 (sw closed) */
    {
    outportb(DATA,0x00); /* turn LED on */
    delay(100);
    outportb(DATA, 0x01); /* turn it off */
    delay(100);
    }
    else
    {
    outportb(DATA,0x01);
    /* if PB not depressed, turn LED off */
    }
    }
    }

    Fig 3 Printer Port - Typical Application
    [​IMG]

    Circuit Description: Logic 1 on output DATA 0 (Data Port - Bit 0) causes LED to be off. Logic 0 causes LED to turn on.

    Normally open push-button causes +5V (logic 1) to appear on input BUSY (STATUS PORT - Bit 7). When depressed, push-button closes and ground (logic 0) is applied to input Busy.

    Note external source of 5V.

    Program Description: When idle, push-button is open and LED is off. On depressing push-button, LED blinks on and off at nominally 5 pulses per second.
    Are you sure? This action cannot be undone.
    Cancel
  • Munguti

    MemberJan 8, 2009

    And could someone tell me how to put images in your site😕
    Are you sure? This action cannot be undone.
    Cancel
  • shalini_goel14

    MemberJan 8, 2009

    Munguti
    And could someone tell me how to put images in your site😕
    Hi munguti,

    Inserting image into post is simple. Just upload your image to popular image hosting sites [ ex. <a href="https://www.flickr.com/" target="_blank" rel="nofollow noopener noreferrer">Find your inspiration. | Flickr</a> ] and copy the complete url of the image [upto the file extension ]. You can do it by right-clicking on the image and selecting "Copy Image Location" option.

    Then click on the [​IMG] button in post editor of CE and insert that URL. Your image will appear inside the post.

    I guess you asked for this only na.😕
    Are you sure? This action cannot be undone.
    Cancel
  • Munguti

    MemberJan 9, 2009

    thanx shalini
    What about the other question ?? 😒
    Are you sure? This action cannot be undone.
    Cancel
  • Munguti

    MemberJan 10, 2009

    Check out this tutorial i found it helpful
    <a href="https://www.epanorama.net/circuits/parallel_output.html" target="_blank" rel="nofollow noopener noreferrer">Parallel port output</a>
    Are you sure? This action cannot be undone.
    Cancel
  • maonin

    MemberOct 15, 2011

    hi#-Link-Snipped-#,

    can you please help me in my project I posted here.
    here's the link to my thread.
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register