How to send logic 1 to pin 3 in Visual Studio 2005. In Visual Basic 6.0 code is simpe: TXD 1, or TXD 0, but I don't know how to do this in Visual Basic 2005, that's important that is logic 1 on PIN 3 of RS232 (serial COM port). Thanks. :)
Printable View
How to send logic 1 to pin 3 in Visual Studio 2005. In Visual Basic 6.0 code is simpe: TXD 1, or TXD 0, but I don't know how to do this in Visual Basic 2005, that's important that is logic 1 on PIN 3 of RS232 (serial COM port). Thanks. :)
Hiyah
I'm pretty sure that PIN3 is used only for receiving data, if you want to do this you'll have to make a custom RS232 cable, where you map PIN 2 to PIN 3.
As for the code, I think you'll just have to send a boolean :)
I'll try and come up with an example if you want... No promises though, I've only sent AT Commands to a modem haha
Hi,
Yeah. Please try to do same examples with this RS232 port. I just want to switch on and switch of one LED on serial port, but code must be write in Visual Studio 2005. Thanks!
Hey
I'm hoping that this code will work for you:
I'm hoping it will send a single bit to pin three, if it doesn't work, it might be worth checking the pin mapping for your device..Code:Dim Port As New IO.Ports.SerialPort("COM1") ''Create the object
Port.Open()
Dim OStream As New IO.StreamWriter(Port.BaseStream) ''Output stream
OStream.Write(True) ''Hopefully this will send a single bit...
I dont know if the code will work... But it's worth a try? :)
Aaron
If you must use Pin3 (Tx Data), and not another pin, then you can control its state after opening the port, by using Break.
Example,
SerialPort.BreakState = True
SerialPort.BreakState = False
More natural, I think, might be to use the RTS output line (Pin 7).
SerialPort.RTSEnable = True
SerialPort.RTSEnable = False
In either case, set the PortName property and call the Open method to enable this. Naturally, I'm talking about the SerialPort control that is in the Toolbox.
Dick
I tried your code. It turns on LED and for 2-3 sec it turns off LED on serial port and give the error. Do you sure I can use RTS with your code?
Just:
SerialPort.RTSEnable = True 'for turn on
SerialPort.RTSEnable = False 'for turn off
I tried this code and when I run it and click button it give me error and exit the program.
When I add "On Error Resume Next" the same thing happened.
What to do?? :(
I have no idea what code you are using, you didn't post it. There should be no error, so your code has a problem.
You cannot say, "I did this," and not say exactly what "this is." I would have to guess, and while I'm good at some things, guessing is not one of them.
Dick
I have done it!
In Form Load
Port.Open
Turning on: Port.DtrEnable = True AND Port.BreakState = True
Turning off: Port.DtrEnable = False AND Port.BreakState = False
Thanks all!
Good. Please mark the thread "Resolved."
Dick