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


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

16 thoughts on “Interfacing Arduino with VGA Monitor”

  1. I’m facing an error:
    class “VGA” had no member “setTextSize”
    class “VGA” had no member “setTextColor”

  2. C:\Program Files (x86)\Arduino\libraries\Adafruit-GFX-Library-master\Adafruit_GrayOLED.cpp:250:10: error: ‘spi_dev’ was not declared in this scope
    if (!spi_dev || !spi_dev->begin()) {
    ^~~~~~~
    can someone help me

  3. I get the same error as Mike & Jacob. I don’t see an answer to their question. Also, why does it call in OLED & I2C routines?

  4. Arduino: 1.8.18 (Windows 8.1), Board: “Arduino/Genuino Uno”

    In file included from C:\Program Files (x86)\Arduino\libraries\Adafruit-GFX-Library-master\Adafruit_GrayOLED.cpp:20:0:

    C:\Program Files (x86)\Arduino\libraries\Adafruit-GFX-Library-master\Adafruit_GrayOLED.h:30:10: fatal error: Adafruit_I2CDevice.h: No such file or directory

    #include

    ^~~~~~~~~~~~~~~~~~~~~~

    compilation terminated.

    exit status 1

    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top