Hello! I was reading a lot about all kinds of programs here for COMport but i need samothing less complicated so i lost interest in rreading kilometer post thet are more advanced form my level. Thnig is that i just need to output 0 or 1, i don't need any strings ore something.. I need my LED to turn on- on my "on" button pressed, and off on my "off" buttnon pressed. Is that complicated? Please dont' tell me to make that on lpt because i have smothing else on lpt...

Thnak you!:)

Dani AI

Generated

A practical, low‑effort way to get a single LED to go on/off from a COM port (answering and following 's question about the environment) is to toggle an RS‑232 control line (RTS or DTR) and use a small interface stage to drive the LED. That keeps the software trivial (no serial protocol required) and the hardware simple.

Hardware notes (must-read): do not connect an LED directly to the DB‑9 pin — RS‑232 lines swing positive and negative voltages and cannot safely source the LED. Use a driver: either an optocoupler or a small NPN transistor (LED + series resistor powered from a 5V/9V supply, transistor switching the LED to ground). Use the DB‑9 ground (pin 5) as common and choose DTR (pin 4) or RTS (pin 7) as the control line. For background on RS‑232 pinouts and voltages see the RS‑232 reference (https://en.wikipedia.org/wiki/RS-232).

Software notes (VB6): open the COM port, then assert/clear the chosen control line. In VB6 you can use the MSComm control or call the Win32 API EscapeCommFunction to SET/CLR RTS or DTR; the port must be open before toggling. See Microsoft docs on EscapeCommFunction for the API details (https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-escapecommfunction).

Quick troubleshooting checklist: confirm the right COM number and that the port is open; measure the control pin with a meter before hooking the LED; ensure the interface handles negative swings; remember many USB‑to‑serial adapters behave slightly differently (drivers may limit control‑line behavior). If hardware design is a concern, using a small microcontroller or USB relay module removes RS‑232 level worries.

Recommended Answers

All 3 Replies

what operating system and compiler?

Visual basic 6.0 on Windows XP

No one van help? I thought it is simple, I gues I was wrong.. was I?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.