Help
i need to turn on a Led using serial control i am using a USB to Serial convert on Windows 7 32bits
Serial1.SerialPort = System.SerialPort(“COM2”)
If Serial1.Open then
Serial1.Write Chr(10)
Else
MsgBox “The serial port could not be opened.”
End if
“Why” is it not working? Are you getting the error message on the serial port “The serial port could not be opened.” or is it just not turning on? What are you connected too? Is the actual data showing up on the port, can you see it with a scope?
Are you sure you have a ground between the two connectors?
Just for a quick try swap the wires on pins 2 and 5.
The first thing that I would do would be to open the ‘Device Manager’ in Windows (the one that gives you a tree-view of all devices on your PC) and look in the ‘Ports COM & LPT)’ section to make sure that your device is available and doesn’t have a yellow warning triangle next to it. I am using a serial device with a Prolific USB-to-Serial Comm Port driver and it is buggy, it often loses its connection and requires a re-installation of the driver, in fact it loses the connection every time that the PC is restarted. Shown below:
Pin.2 is receive-data, Pin.5 is ground - I’m not a hardware person, but you might find you should be using Pin.3 ( transmit data) rather than Pin.2 at the 9-pin connector ( transmit on PC being then passed to Recieve on your electronics board.
Sending a character will only raise a signal for a short time - which is OK if you have some electronics that understand that the character you are sending should light your LED
If not, and you are looking for a signal to set high or low and remain high or low until you change it, then you could use
one of the other signals, such as :-
Serial1.DataTerminalReady = true/false (Pin.4)
Serial1.RequestToSend = true/false (Pin.9)
For what it’s worth…
when I open a serial port I normally some properties every time, for example…
if Serial1.Open then
Serial1.Baud = 9600
Serial1.Bits = Serial.Bits8
Serial1 = Serial.StopBits1
Serial1.Parity = Serial.ParityNone
…
end if