Interfacing Arduino with VGA Monitor

This post shows how to connect VGA monitor with Arduino UNO board in order to draw shapes (lines, circles …) and print texts with resolution of 160×64 pixel.
VGA: Video Graphics Array

Hardware required:

  • Arduino UNO board
  • VGA monitor
  • 2 x 68 ohm resistor
  • 220 ohm resistor
  • VGA connector
  • Breadboard
  • Jumper wires

Interfacing Arduino with VGA monitor circuit:
Example circuit diagram is shown below.

Arduino VGA monitor circuit

HSYNC (horizontal synchronization) pin of the VGA connector (pin #13) is connected to Arduino digital pin 3 through 68 ohm resistor.
VSYNC (vertical synchronization) pin of the VGA connector (#14) is connected to Arduino digital pin 10 through 68 ohm resistor.

Color pins (R: red, G: green, B: blue) of the VGA connector (respectively #1, #2 and #3) are connected together in order to get white and black colors, they are connected to Arduino digital pin 7.

Interfacing Arduino with VGA monitor code:
The following Arduino code requires two libraries:

The first library is a simple and small library for generating the required signals (VSYNC, HSYNC and video).
The VSYNC (vertical synchronization) signal is generated on pin 10.
The HSYNC (horizontal synchronization) signal is generated on pin 3.
The video signal is generated on pin 7.

Timer2 Module is configured to generate a compare match interrupt every 32 microseconds (31.25 kHz), the horizontal synchronous pulse is generated as a PWM signal with frequency of 31.25 kHz. Within this interrupt the Arduino outputs vertical synchronization pulse and video signal.

This library disables Timer0 interrupt which means the following functions will not work anymore:
unsigned millis();
unsigned long micros();
void delay(ms);
void delayMicroseconds(us);

Instead of delay(ms) function the VGA library has an other one with the same name.
Arduino VGA library can be downloaded from the following link:
Arduino VGA library

After the download of the library, put its files (VGA.h and VGA.ccp) in Arduino sketch folder.

The VGA library works with Adafruit graphics library which can be downloaded from the following link:
Adafruit graphics library        —->  direct link

Full Arduino code:

The image below shows my hardware circuit result:

Interfacing Arduino with VGA monitor

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.