The Due VGA library lets you connect a Due to a monitor with a VGA input. Resolutions available are up to 800x600 in monochrome and 320x240 in colour. The API is quite simple and straightforward - just VGA.begin(x,y); and off you go! The library has some common drawing functions for pixels, lines, triangles, rectangles, circles, ellipses and text. It also derives the Print library, so it supports the Arduino VGA.print(...) and VGA.println(...) functions. Just 3 resistors needed for mono and 10 resistors for colour.
Github page http://stimmer.github.com/DueVGA/
Download: DueVGA-0.512.zip
Update 12/05/2013 Version 0.512: Fixed interrupt handling so the library now works better with Serial and Audio libraries, and added some longer demos (display of data from GPS, showing animation from an SD card, and a waterfall visualization of an audio input signal)
Update 04/04/2013 Version 0.404: Added PAL/NTSC colour composite modes for TV output. Circuit is 6 resistors and (if needed) one capacitor.
Update 14/03/2013 Version 0.314: Colour mode now uses DMA, making it 4 times faster than before 8) - the Mandelbrot demo used to take about 4 minutes, now it is finished in under 1 minute. Also fixed a bug involving analogWrites to pin 2, and added keywords.txt for source highlighting.
Example code:
#include <VGA.h>
// DrawingTest
// test of all drawing functions
void setup() {
VGA.begin(320,240,VGA_COLOUR);
}
double a=0;
void loop() {
int x0=random(320),y0=random(240),x1=random(320),y1=random(240),x2=random(320),y2=random(240);
VGA.fillTri(x0,y0,x1,y1,y2,y2,random(512)-256);
VGA.drawTri(x0,y0,x1,y1,y2,y2,random(512)-256);
x0=random(320);y0=random(240);x1=random(320);y1=random(240);
VGA.fillRect(x0,y0,x1,y1,random(512)-256);
VGA.drawRect(x0,y0,x1,y1,random(512)-256);
x0=random(320);y0=random(240);x1=random(320);y1=random(240);
VGA.fillEllipse(x0,y0,x1,y1,random(512)-256);
VGA.drawEllipse(x0,y0,x1,y1,random(512)-256);
x0=random(320);y0=random(240);int r=random(70);
VGA.fillCircle(x0,y0,r,random(512)-256);
VGA.drawCircle(x0,y0,r,random(512)-256);
x0=random(320);y0=random(240);r=random(5)-1;
VGA.drawText("Hello Arduino!",x0,y0,random(256),random(256),r);
x0=random(320);y0=random(240);r=random(5)-1;
VGA.drawText("Due VGA Library",x0,y0,random(256),random(256),r);
VGA.scroll(0,0,320,240,8*sin(a),8*cos(a));
a+=0.05;
}
For monochrome modes the circuit is very simple - just 3 resistors
Connect pin 42 through an 82 ohm resistor to VGA VSync (pin 14 on VGA D-connector)
Connect pin 43 through an 82 ohm resistor to VGA HSync (pin 13 on VGA D-connector)
Connect GND to VGA GND (pins 5,6,7,8,10 on VGA D-connector)
Connect SPI MOSI pin (bottom middle pin on 6-pin SPI connector) through a 100 ohm resistor to VGA Red, Green and Blue pins (pins 1,2 and 3 on D-connector)
You may need to experiment with the values of the resistors for best results.
For colour the circuit needs a few more pins and resistors:
Due pin 34 -> 820R resistor -> VGA pin 3 (blue)
Due pin 35 -> 390R resistor -> VGA pin 3 (blue)
Due pin 36 -> 2k2 resistor -> VGA pin 2 (green)
Due pin 37 -> 1k resistor -> VGA pin 2 (green)
Due pin 38 -> 470R resistor -> VGA pin 2 (green)
Due pin 39 -> 2k2 resistor -> VGA pin 1 (red)
Due pin 40 -> 1k resistor -> VGA pin 1 (red)
Due pin 41 -> 470R resistor -> VGA pin 1(red)
Due pin 42 -> VGA pin 14 (VSync)
Due pin 43 -> VGA pin 13 (HSync)
Due pin GND -> VGA pins 5,6,7,8,10
Again the resistor values probably aren't optimal.
For PAL/NTSC:
Due pin 36 -> 3k3 resistor -> Video In
Due pin 37 -> 1k5 resistor -> Video In
Due pin 38 -> 820R resistor -> Video In
Due pin 39 -> 390R resistor -> Video In
Due pin 40 -> 200R resistor -> Video In
Due pin 41 -> 100R resistor -> Video In
Due pin GND -> Video GND
You may need a 100uF capacitor between the resistors and Video In for DC blocking.
I shall keep this post updated with the latest library release so keep checking back here. Have fun!