Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blink LED using Visual C++

Tags:

c++

I am new to vc++, I have to create a simple vc++ application so that I can turn off or turn on an LED ( or an electrical bulb powered by a cell), How can I take the control out from my program, I would like to use a USB for connecting the output.

Is there any library available for implementing USB integrating in the program ?

like image 208
john Avatar asked Jul 31 '10 05:07

john


2 Answers

Have a look into the FTDI FT232RL series of chips. They're so common that the driver is already included in most operating systems. It's a USB-to-serial device, but it has a "bit bang" mode which turns the serial lines into individually addressable IO lines that can be used either as signal lines for your own protocol, or to so simple things like drive an LED.

Hack a Day has a great tutorial on using this device to (believe it or not) blink an LED connected via USB, including sample code written in C. Find the tutorial here: http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/

The chips are easy to come by. The chip itself costs about $4 on its own, or you can spend about $15 to get it on a breakout board with a USB connector and such. Many USB-to-serial cables or converter boxes, or even the adapter cables for older cell phones contain this chip inside to do the actual translation, so if you have such a thing lying around already, you may want to try it.

like image 76
tylerl Avatar answered Oct 08 '22 10:10

tylerl


USB does not have any ability to drive a LED directly; you will need an interface circuit. That circuit will need driver software, and this will determine how the software will operate. It is impossible to know how to write the program without knowing the driver.

You might have better luck using the legacy parallel port rather than USB. I can't direct you to any resources, but a quick search (even here on StackOverflow) should turn up something.

like image 21
Mark Ransom Avatar answered Oct 08 '22 09:10

Mark Ransom