By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

Turning Lights On with Computer

P: 84
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!
Aug 28 '07 #1
Share this Question
Share on Google+
8 Replies


Banfa
Expert Mod 5K+
P: 8,916
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..
Aug 28 '07 #2

P: 41
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
Aug 29 '07 #3

P: 84
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!!
Aug 29 '07 #4

Banfa
Expert Mod 5K+
P: 8,916
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).
Aug 29 '07 #5

P: 84
It should work under Windows XP
Aug 30 '07 #6

Banfa
Expert Mod 5K+
P: 8,916
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 (ExxcapeCommFunction looks like your only option) as well as looking up the functions CreateFile, ReadFile, WriteFile and CloseHandle on the MSDN website.
Aug 30 '07 #7

Expert 10K+
P: 11,448
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
Aug 30 '07 #8

P: 84
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!
Sep 6 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.