Turning Lights On with Computer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluesteel
    New Member
    • Mar 2007
    • 84

    Turning Lights On with Computer

    I wanted to make a program to turn on my bedroom lights. I wanted to use the serial port, and i need to know a function that handles serial port outputs. I wanted to give either 0 or 1 at the output of a single pin, then i would make a circuit that let AC go through the wires if the computer returned 1 via such pin. I need to know what function can handle this, this would be great for learning but also it would be awesome to turn on the lights trough the computer! Imagine, using serial port i could turn on many devices, lights, tv, dvd player and a lot more! It would be great, please help me here!

    Help is much appreciated.

    Paul.
    Thank You a lot!
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    What OS are you using?

    Also what you are suggesting is not a real use for a serial port, I guess you probably could toggle one of the ports control lines to get you 0 or 1 but it is hardly serial programming.

    Serial programming would be connecting the port to a digital io module and reading/writing data via RS232..

    Comment

    • jpenguin
      New Member
      • Aug 2007
      • 41

      #3
      Originally posted by bluesteel
      I wanted to make a program to turn on my bedroom lights. I wanted to use the serial port, and i need to know a function that handles serial port outputs. I wanted to give either 0 or 1 at the output of a single pin, then i would make a circuit that let AC go through the wires if the computer returned 1 via such pin. I need to know what function can handle this, this would be great for learning but also it would be awesome to turn on the lights trough the computer! Imagine, using serial port i could turn on many devices, lights, tv, dvd player and a lot more! It would be great, please help me here!

      Help is much appreciated.

      Paul.
      Thank You a lot!
      this sounds a little difficult. you might just want to use an X-10 system, there is probably a version for your OS

      Comment

      • bluesteel
        New Member
        • Mar 2007
        • 84

        #4
        When you say it is not necessary to use serial port you are right, but i really want to avoid using parallel, and i don't know any other ports i could use. All i need to know is a function to handle serial port outputs. I searched info about it but i cannot get anything interesting. All the help i need is what function i can use in c++. Please help me. I really want to make this work!!

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Originally posted by bluesteel
          When you say it is not necessary to use serial port you are right, but i really want to avoid using parallel, and i don't know any other ports i could use. All i need to know is a function to handle serial port outputs. I searched info about it but i cannot get anything interesting. All the help i need is what function i can use in c++. Please help me. I really want to make this work!!
          You still haven't said which OS you are using. There are no standard library functions for handling serial ports (because so many platforms don't have/need them).

          Comment

          • bluesteel
            New Member
            • Mar 2007
            • 84

            #6
            It should work under Windows XP

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Originally posted by bluesteel
              When you say it is not necessary to use serial port you are right, but i really want to avoid using parallel, and i don't know any other ports i could use. All i need to know is a function to handle serial port outputs.
              I didn't say that it was not neccessary to use the serial port, I said that this was not a proper use of it. The serial port does not really have outputs in the way you want to handle them, what you should do if you want to do this is connect a serial IO device, like those available from Weeder Technologies to your port and send RS232 data in the normal way to the device.

              However it you really want to do it your way then you will need to look at the communication function reference (ExxcapeCommFun ction looks like your only option) as well as looking up the functions CreateFile, ReadFile, WriteFile and CloseHandle on the MSDN website.

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by bluesteel
                It should work under Windows XP
                As already suggested above, use one or more X10 units. You don't want those poor
                5Volt thingies next to those 110/220V wires.

                kind regards,

                Jos

                Comment

                • bluesteel
                  New Member
                  • Mar 2007
                  • 84

                  #9
                  Originally posted by JosAH
                  As already suggested above, use one or more X10 units. You don't want those poor
                  5Volt thingies next to those 110/220V wires.

                  kind regards,

                  Jos
                  Thanks for your post, but i didn't mean that. I meant using serial port as a signal. I will make a device that lets 110/220v turn on the lights only if serial port sends a positive signal. I am not using serial to turn on the lights under any circumstances! I need a function that sets voltage in serial pins to high or low when i want. That's what i need. Just to tell my device whether it should turn on the lights or not. Thank you all for your help!

                  Comment

                  Working...