I am trying to use MatLAB script as an on/off switch. In simple words, I wish to set a constant output of ~0V (low) or ~5V (high) at the USB port whenever I need to. How could I do this in a most simple and inexpensive way?
This cannot be done directly with USB. USB is a shared serial bus, and only digital signals can be carried on it. If you were to use USB you would need to have a USB-interfaced device on the other end that decoded the serial commands to turn a switch on or off.
One important question for this purpose is what kind of rate of change do you need for this purpose? Another question is what precision you need in the timing. A third question is how much control you need over the pulse widths.
For $89 or so you can get a USB device that you can read pins from. See http://www.mccdaq.com/usb-data-acquisition/USB-1024-Series.aspx
Play games and win prizes!Learn more