[vb.net] Turn off COMPORTS and turn it on
I have a led with a resistor soldered on a USB cable with a resistor when I put it on the USB comport1 it turns on, but I would like to turn it off or reduce to almost zero the power flow in the serial port, being able to turn it on and off, I looked for some articles but always take me to ardruinos or some other type of control board, I wanted something directly on the computer to turn the comport on and off, I am aware that this is dangerous and can damage it, but I want to test this directly on the computer is there any way to do it this with visual basic?
Re: [vb.net] Turn off COMPORTS and turn it on
You can toggle the state of the RTS line very easily. This will set it HIGH on COM1:
Code:
SerialPort1.PortName = 1
SerialPort1.Open()
SerialPort1.RtsEnable = True
and closing the port will set it LOW:
Code:
SerialPort1.Close()
Make sure you use the highest value resistor that still lights your LED. Com ports can only sink and source a couple of milliamps.
EDIT: This assumes you are using a serial to USB converter that gives you all the standard serial port pins. It won't work with just a USB connection.
Re: [vb.net] Turn off COMPORTS and turn it on
Quote:
Originally Posted by
paulg4ije
You can toggle the state of the RTS line very easily. This will set it HIGH on COM1:
Code:
SerialPort1.PortName = 1
SerialPort1.Open()
SerialPort1.RtsEnable = True
and closing the port will set it LOW:
Code:
SerialPort1.Close()
Make sure you use the highest value resistor that still lights your LED. Com ports can only sink and source a couple of milliamps.
EDIT: This assumes you are using a serial to USB converter that gives you all the standard serial port pins. It won't work with just a USB connection.
well I used a cut USB cable with the led and the resistor so I assume it will work when I'm at home.
Re: [vb.net] Turn off COMPORTS and turn it on
It's not going to work without a serial to USB converter. USB is a bus, not a port.
Re: [vb.net] Turn off COMPORTS and turn it on
There is the serial bus portion of USB but there is also pins to provide ground and power for the device plugged in.
I assume he is hooking the LED to the power pin. The USB device can provide a variable amount of current, which is usually negotiated by the device.
There is probably a way to turn the power off and on programmatically, probably by enabling or disabling the USB port, but I haven't researched it.
Re: [vb.net] Turn off COMPORTS and turn it on
You can turn off a USB device, but I doubt there is an easy way to turn off the +5 volts on an individual USB port.
Re: [vb.net] Turn off COMPORTS and turn it on
Probably one of the better options is a USB to UART cable or development board that exposes its I/O. One of the more popular manufacturers is FTDI who make a 5v and 3.3v.
Here is a link to a variety but if you google you can find them at many online stores:- https://ftdichip.com/product-categor...-cable-series/
Once you have the cable then FTDI have libraries for VB.net and C# (with examples) that allow you to control the I/O lines from a PC.
The methods include being able to configure the I/O as output and to switch them on and off