Basically, I want to create a countdown timer. Which isn't hard. It's all over the web. BUT I would like to know how and what I would need for, when the timer reaches zero, the code commands a relay to close, allowing voltage to flow to something. Also, presetting the timer is a must and, if possible, checking for proper voltage going to the relay would be a HUGE plus. If the conditions aren't right, the program terminates and displays an error message explaining what went wrong.

I'm fairly new to C++ and am trying to learn everything correctly, but haven't been able to find any answers. I know this idea sounds crazy, but it's for a school project and I'd love to be able to figure it out.

Any help is greatly appreciated.

Edit: If the countdown timer could be displayed on a digital displays screen, instead of just in the program, that would be HUGE points for me. I know I'm gonna need to use some sort of serial port connection, a microcontroller (I think) and who-knows-what-else. If anybody could help, as well as point out the hardware I'd need to accomplish this, it would be a lifesaver.

Recommended Answers

All 6 Replies

Hey, I do something similar for work. I use a DLP-IOR4 board to bridge connections. It's USB attached and utilises a virtual com port.
It's very easy to use, just two simple commands fired down the serial port.

http://www.dlpdesign.com/usb/ior4.shtml

There are other more powerful and better rated models, choose the right one for your circuit =)

commented: Good suggestion. +14

I noticed that this is "latched". I need the relay to be "open" (no power going through it, and then "Close" on command to complete the circuit. Also, it is possible to hook up an external supply of power to this? What my computer can put out through the USB isn't gonna be enough.

The specific unit I showed you is not USB powered and requires an external power supply to power whatever device you decide to attach to the relay. The board is literally just that, a software logic relay switch.

There are 4 "switches" which you set to either the A or B position depending on how you wired it up.

So you design your circuit to be "closed" on contact B of switch 1. To open (disable) the circuit. You set switch 1 to A. To close the circuit, you set switch 1 to B. :)

The specific unit I showed you is not USB powered and requires an external power supply to power whatever device you decide to attach to the relay. The board is literally just that, a software logic relay switch.

There are 4 "switches" which you set to either the A or B position depending on how you wired it up.

So you design your circuit to be "closed" on contact B of switch 1. To open (disable) the circuit. You set switch 1 to A. To close the circuit, you set switch 1 to B. :)

Does this switching have to occur manually i.e. by hand? Or can a C++ program control the switching? I'm looking for an option B, but then, like I said, maybe this is too advanced for me and I don't even know what I'm talking about or getting into.

EDIT: You said it just requires 2 simple commands to be sent to it. So I'm assuming it'll do what I want it to do. So thank you. I should have read more carefully. I really have no knowledge on logic switches so I have some reading to do. If there's anywhere I could go to start learning, could you please point me in the right direction? Thank you SO SO much.

I suggest purchasing the hardware I linked or something similar and having a look at how it works. They are very easy to use :)

Literally, open COM port, send command for on, send command for off. Nothing else is required. There is no feedback mechanism in these types of units (but you can get ones that do)

I suggest purchasing the hardware I linked or something similar and having a look at how it works. They are very easy to use :)

Literally, open COM port, send command for on, send command for off. Nothing else is required. There is no feedback mechanism in these types of units (but you can get ones that do)

Thank you so much! This is making things much easier to understand and work with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.