Go Down

Topic: VGA library - now with TV output (Read 34790 times) previous topic - next topic




What about UNO board support? It makes sense to have light version of lib...
DueVGA is too dependent on hardware features only available in the SAM3X chip in the Due (particularly DMA) so it would be impossible to port it to the Uno.

Sure, but some VGA out also possible at UNO board too - http://forum.arduino.cc//index.php?topic=102181.0


Hello, first of all! Awesome work!

I would like to ask you some questions abuot the project. Im interested in doing something similar.

The first question is if would be any problem to increase de nomber of bits to 12  (4 bits each color) with a new resistor matrix.

The second question is about my idea. I would like to ask you if you think it would be possible. Im thinking on joinin togueter the vga controller with a CMOS camera, thus streaming the image directly to the vga. Im planing to use a ov7670 + Fifo camera.

Thank you in advance,



There are a couple of problems with getting DueVGA to output 12-bit colour: firstly because of the way the DMA and external memory interface work it would mean using 16 bits for each pixel. The second problem is lack of memory - there would only be enough memory for a resolution of about 240x160 at 12/16bpp.

How were you intending to connect the two? It may be possible to use the Due to generate the VGA timing signals for tha camera, and possibly generate some graphic overlay. It would be hard to capture the frame into the Due (because of lack of memory) but may be possible at low resolution / grayscale.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


Thank you for you response! I see, then i would keep the 8 bits output.

And aobut the camera, what do you think without of having two memorys? I mean, for instance creating a buffer line then, capturing one line of the camera, and while the second line is preparing (there is a delay between every line) drawing this information on the VGA.  Using interrupts to get the data would interfere to the vga generation?

I have been reading through your library and it's a hard work what you have done. I am impresive!  I would be very interested in knowing exactly how do you generate the signals with the timers.  I already have been playing a little with tiemrs and interrupts in my arduino uno but no in the way it's written in you code.

If you have time and inclination I would thank you quite a lot  (and I amb sure others people too) if you can explain a little lines responsible for this task!

Aitor Sanchez

How much ram does the pixel data take?
Can we have double buffering, by using 2 arrays of pixel data and then swapping pointers?
I'm considering purchasing the Arduino Due for this library and I'm wondering what to expect.


320x240 colour mode takes about 76k, 800x600 mono is about 60k. There really isn't enough memory for double-buffering so I am not likely to add it to the library.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

Ok, interesting thank you very much. Can I ask two more questions?
The first is can I lower the colours down to 4 bit greyscale?  this would mean it uses halve as less space as 8 bit at 320x240. allowing another buffer, correct?
The second is to rewire the hardware to support 8 bit greyscale, I would only need an 8 bit DAC then wire the result to the red, blue and green.
If I can do this then how do I pick my resistor values or how did you pick the needed values for the 8 bit color? I understand it is to do with ohms law but I just can't get my head around it so seeing it in use should help me out a lot.

Thank you for your time.


The library doesn't support 4-bit modes. I can't think of an easy way of doing them in a way the hardware supports.

However, I just tried the library in a very low resolution mode (256x150) and it worked! This should only use 37.5k, so double buffering ought to be possible, if you can accept a resolution that low.

It's difficult to make a full 8-bit-accurate DAC with standard resistors. It's quite easy to get 5 or 6 bits accuracy though. You could try the PAL/NTSC TV out circuit for this (it is just a simple 6 bit DAC). There might be a problem with driving all 3 colours, you might find the impedance is too low and the picture ends up too dark. You can only experiment and find out for yourself.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

Simple color Cellular Automata :-)

Code: [Select]

/* Simple color Cellular Automata v1.0 */

#include <VGA.h>
  int iter = 240;
  int lngt = 320;
  int st[320];
  int k;

void setup(){
  for (int i=0;i<lngt;i++) st[i]=random(256);


void loop(){

   for (int i=0;i<iter;i++) {

      for (int j=0;j<lngt;j++) {
         k = k ^ st[j];
         st[j] = k; }
       for (int j=0;j<lngt;j++) {
         k = st[j];

Hi stimmer

This is bug or not ?

I downloaded your latest V0.987654321 - 23/11/2013 library and when set 320x240 color resolution real resolution is only 320x200 (640x400 monitor info) this is normal or bug ? Old library working full 320x240.

Many thanks info about it



Nothing significant has changed in the latest release except for a bug fix to the clear method.

Sometimes the monitor guesses the wrong mode from the input signal - it's impossible to get the timings exactly right. Experimenting with setMonitorFreqRange and setSyncPolarity might help trick the monitor into showing 320x240 properly.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


Ahaaa :-)

Many thanks quick info.


Giuseppe G.

Hello Stimmer. There is a list of commands used and descriptions on library with VGA?

Giuseppe G.
Un saluto a tutta la comunità.
Giuseppe G.


    I used the VGA mode to connect and display graphics in color on my PC monitor in the past.  That has worked great.  Recently I've been working with an older TV set (from the '80s) in NTSC mode.  I've gotten a stable picture to display on the TV, but I'm only getting monochrome there.  Is that intended?  From the README.txt file I gathered that the NTSC and PAL mode TV output would be color.

    If color is intended in NTSC mode, I need to determine why I'm not getting color.  It's possible that my resistor divider for the DAC is not correct.  I used the same resistors as I used for the computer VGA, which I thought would work, even if the colors weren't perfect.  I suppose that if my resistors were too small, I might be saturating the voltage all the time and turning the display white.

    The color data I'm sending is in RRRGGGBB format, but I noticed the pin-out in the README.txt for NTSC/PATL is only 6 pins.  Is there some discrepancy here?  Are we really only getting 6-bit color in NTSC / PAL?

Any info is much appreciated,


The circuit for NTSC (and PAL) is on this page: http://stimmer.github.io/DueVGA/tvout.html . Getting as close as you can to the correct values of the resistors is very important.

You can extend it to 8 bits if you want - you need 6.4k on pin 35 and 12.8k on pin 34 - the reason I didn't include them is because if you're using 1% tolerance resistors they won't add significantly to the precision of the output.

The NTSC code uses all 8 bits of colour data to synthesize the NTSC signal.

The older the TV is the less chance of getting colour output. The signal generated by my code is somewhat out of spec. Modern TVs are much more tolerant of badly generated signals than old CRT sets. It's best to try and get it working on a newer TV first, then try it on the old TV. I have had it working in PAL on a colour monitor bought in 1991 and in NTSC on a colour TV from about 2003.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131