i need turbo c program for controlling led's using push buttons or switches..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doyan
    New Member
    • Jul 2010
    • 5

    #1

    i need turbo c program for controlling led's using push buttons or switches..

    this is the given problem...

    If switch 1 is pressed then led's will light alternately from left to right..
    If switch 2 is pressed then led's will light alternately from right to left...

    this is connected to parallel ports...
    please help me...
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    This is an electronics problem.
    You need to get the circuitry right first and make it work mechanically.
    Then replace the mechanical switches with relays.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      How many LEDs?
      How are the LEDs connected to the computer?
      When you say "will light alternately", do you mean there is never more than one LED lit at a time or do you mean that all of the LEDs turn on one after the other?
      How much time should elapse between each change in LED state?

      Comment

      • doyan
        New Member
        • Jul 2010
        • 5

        #4
        there are 4 LEDs...
        LEDs are connected through a parallel port...
        it will light one at time.....exampl e... led 1 will light,then 2,3,4..then after that it will light light from 4, then 3,2,1...if led 1 will light,2,3,4 are off...if led 2 will light 1,3,4 are off and so on...
        there should be 1 second interval...

        please i need it badly...

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          A quick google found this project

          Comment

          • doyan
            New Member
            • Jul 2010
            • 5

            #6
            @code green...sir,i find that link very useful but i don't know how to make a program that would fit my problem which is making light on from left to right and right to left...
            could you help me make the program?

            please??

            Comment

            • doyan
              New Member
              • Jul 2010
              • 5

              #7
              could you help make a program about LED connected to parallel port..

              4 LED's will light from left to right if switch 1 is pressed and it will light again from right to left if switch 2 is pressed...

              should have 1 sec elapse/interval time....

              please?
              Forward Message

              Comment

              • code green
                Recognized Expert Top Contributor
                • Mar 2007
                • 1726

                #8
                The algorithm is to have an array of port addresses corresponding to the LED connections of the parallel port.

                Code:
                Poll the switches looking for a message
                {
                 Loop through the array
                 {
                    Send address low (switch off)
                 }
                
                 Check which switch is pressed then loop through the array
                 either forwards or backwards
                 {
                    Send the port address high.
                    Delay a second or so.
                 }
                }

                Comment

                • donbock
                  Recognized Expert Top Contributor
                  • Mar 2008
                  • 2427

                  #9
                  Start with the basics. Do you know how to manipulate the parallel port to light a single LED?

                  Create a subroutine that lights whichever LED is specified by the argument. Then create two additional subroutines: one that sequentially lights the LEDs from left to right; and one that sequentially lights the LEDs from right to left. Finally, write a main program that decides when to call each of those sequential-LED functions.

                  Comment

                  Working...