7

I just connected an LED to a parallel port in my PC and controlled it successfully through inpout32.dll

I was wondering, if it was possible to do the same with the VGA port. Where can I find information about the functions and layout of the pins of a VGA port and how to use it to light up an LED?

Tried to search myself but was really tough - any Google search using the terms "VGA" and "LED" is only resulting in the TV and Monitor related websites.

  • Since I am new to electronics field (but not SE), a comment on the reason for downvote would enlighten me. –  Jan 07 '13 at 14:41
  • I'm unsure of the down vote, but to answer your question, I think not, but I don't know for sure. I say no because I think the RGB signal doesn't have enough voltage, however the SYC and some other lines may, but they are not intended to be used this way. – Garrett Fogerlie Jan 07 '13 at 14:45
  • If you don't have a parallel port available, it would be much easier to output a digital signal using an RS-232 port (either a real COM port or virtual COM port USB->RS232) and setting the DTR lead high. It will switch from -5 (or lower) to +5 (or higher). – tcrosley Jan 07 '13 at 18:33

4 Answers4

6

This is probably a better pinout

The video and sync signals are 0-1V and not under software control; they're connected to the video hardware output of your card. You might be able to put the card into "power saving" mode and turn them off altogether, but you don't have the fine-grained control that is possible with the parallel port.

There's also a 5V signal, and the I2C signalling used for "EDID" monitor detection (this allows the computer to know which resolutions are acceptable). It might be possible to access that more directly from software, and likewise it might be possible to turn the 5V off by disabling the card or putting it into power saving mode.

Anything that you do discover will depend on the model and drivers for your video card.

Note that, given the ability to toggle a pin at a high enough rate, you can do the reverse: generate video from something that is not a video output.

It's also possible to use the video card to output an RF signal: http://bellard.org/dvbt/

pjc50
  • 46,540
  • 4
  • 64
  • 126
  • 2
    The video signals on the VGA connector are *very much* under software control; after all, it's software that controls everything you see on the screen! – Dave Tweed Jan 07 '13 at 15:09
  • 1
    video card to output an RF signal? You guys are crazy. +1 voted , Thanks , nice idea. – Standard Sandun Jan 07 '13 at 15:10
  • 1
    Not _direct_ control. Bellard's DVB-T system is a spectacular hack which relies on knowing a lot about signal processing :) – pjc50 Jan 07 '13 at 15:15
  • @DaveTweed software controlled yes, but I would think that there is either a hardware or firmware issue that would prevent this from being done on a computer, especially if running an OS like windows. But I don't know enough to say that for sure. – Garrett Fogerlie Jan 07 '13 at 15:54
  • I am completely clueless about this, hence the question: apart from the thrill of doing something that is apparently very tough.. what's all the excitement about the VGA to VHS thing? :D –  Jan 07 '13 at 16:12
  • @GarrettFogerlie: Every OS I know of has a way for an application program to go "full screen", which means that it can directly control every pixel on the screen. – Dave Tweed Jan 07 '13 at 16:26
  • @DaveTweed every pixel, yes and even a range for the refresh rate. But isn't this is still sent to the video processor via the bus and I don't see how you could create a constant dc voltage to power an LED this way. When I get the time I may educate myself further with how this may be done. thx – Garrett Fogerlie Jan 07 '13 at 16:36
  • 1
    You can control what's on the screen, but not necessarily what's off the screen (blanking interval, borders, sync etc.) I'm now reminded of the Sinclair Spectrum and its flashing border during tape loading .. – pjc50 Jan 07 '13 at 16:43
  • 1
    Hypothetically, one could set the on-screen area the same as the off and get a mostly "off" output, or set the on screen area to contrast with the off screen area, and get an output that is driven enough of the time to be turned into a steady level with a little filtering in the current driver circuit that would likely be needed anyway. – Chris Stratton Jan 07 '13 at 16:50
2

If I remember correctly, the VGA sync outputs switch polarity to instruct antiquated monitors to switch their vertical refresh rates. Thus, each sync wire will be high most of the time in some modes and low most of the time in others. When using a newer monitor with a vintage VGA card, it would probably be possible to change the sync polarity as a means of controlling an LED; newer monitors probably wouldn't care about the sync polarity, though switching it might cause a momentary display glitch.

Alternatively, one could probably construct a circuit using a 556 or similar dual timer, a fast analog comparator, and a 74HC74 or similar dual flip-flop, to latch the state of a particular region of the screen. One of the timers should be set for a delay of around 2-12ms triggered by vertical sync, and one should be set for a delay of 20us or so triggered by the horizontal sync. The second timer should trigger one latch to capture the state of the first timer, and output of that latch should trigger the second latch, which should capture the state of the comparator, which should check the voltage on the R, G, or B pins.

The net effect of the circuit would be to have the state of the LED indicate whether the brightness of a particular "pixel" was higher or lower than a certain threshold. By adjusting the timers, one could control which pixel was output. For reliability, one would probably have to display a rather large rectangle rather than a single pixel, but this approach could easily be extended to work with dozens or hundreds of LEDs.

supercat
  • 45,939
  • 2
  • 84
  • 143
0

Here is information on VGA: http://en.wikipedia.org/wiki/VGA_connector

But you cannot control the pins of the connector directly. The only thing you can do is write to the screen and the VGA will output something different.

  • Are you saying the only way to send signals through VGA port is `Software > Video Memory > Port` and the final output need not necessarily be under our direct control like in the Parallel Port? –  Jan 07 '13 at 14:52
  • 1
    Except for maybe some very low-level programming (which would be very hardware-dependent and probably beyond the capabilities of most of us here) that is correct. Same is true BTW for USB and Ethernet. – Wouter van Ooijen Jan 07 '13 at 14:54
  • @SenthilKumar Exactly. VGA is controlled by a graphics card, so not directly by the processor. There also are no such things as VGA drivers except the one that is built-in. Also, when you look at the VGA connector link in my answer, you'll see every pin is used by the VGA protocol and therefore is determined by the screen output. So I'm sorry, but that's the case :-( –  Jan 07 '13 at 14:56
  • @WoutervanOoijen: do you know if there are low-level programming languages that allow you to control the VGA connector? I wouldn't think it is possible because VGA is behind a graphics card. –  Jan 07 '13 at 14:57
  • It's not a question of what language is used - it is as you say a function of what it's connected to. – pjc50 Jan 07 '13 at 14:59
  • 1
    It is not about the language. If it can be done at all in any language it can probably be done in every other (decent = non-sandboxing) language. The problem is finding out how, which (if possible at all) is probably buried deeply in some undocumented test mode of the particular graphics chip or card. To put it into perspective: if you have ever written a graphics driver for a PC you might stand a chance (snowflake in hell level). – Wouter van Ooijen Jan 07 '13 at 15:00
  • 2
    VGA screen = millions of little lights you already know how to control. LED = one big light, hard to control through VGA. Why would you want to substitute the latter for the former? Just draw a picture of an LED on the screen! – Dave Tweed Jan 07 '13 at 15:15
  • This answer is substantially inaccurate. What can be done in terms of manipulation of the pins depends on the architecture of the video controller. It is quite possible that by altering the detailed timings one could create at least the impression of having the LED mostly on or mostly off. However, external current amplification might be necessary. – Chris Stratton Jan 07 '13 at 15:39
  • The asker wants to know if it is possible to do the same with VGA as with parallel. I did not read that as only achieving the same result, but in a way familiar to that with the parallel port. I therefore think abusing the VGA protocol to achieve the same result is out of the scope of this question. But I might be wrong. @SenthilKumar? –  Jan 07 '13 at 15:43
  • 1
    @CamilStaps I was expecting to be able to control the signals in the VGA port directly since I didn't know the internal working. But I was also half-expecting to be able to do it only through some convoluted way that I could still handle at the software end. But it looks like even *that* is not practically possible, and for myself the answer seems to be **no**. You were correct nonetheless :) +1 –  Jan 07 '13 at 15:48
  • @SenthilKumar, no, you actually can do this by reprogramming the VGA timings. And you probably do not need to go beyond the level at which most graphics cards are comparable. However, you'll be messing around in things that the operating system usually takes care of, so the work environment may be uncomfortable - unless you are running the machine headless, you'll need to make sure you have another working graphics port which you don't disturb. USB microcontrollers are pretty cheap and a lot more flexible. – Chris Stratton Jan 07 '13 at 16:48
0

I can light up an led by putting it to pins 6/7 (-) and 12 (+). It worked constantly for over a year, still continues to work and supplies the led with 2-3 volts with relativly low current. I don't know is it making any damage, but no errors has been recorded yet.

ResR
  • 21
  • 1