Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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.
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:

/*************************************************************************
*
* VGA output with Arduino (white and black colors).
* This is a free software with NO WARRANTY.
* https://simple-circuit.com/
*
************************************************************************/

#include <Adafruit_GFX.h> // include Adafruit graphics library


#include "VGA.h" // include VGA library

// initialize the VGA library


VGA display = VGA();

void setup(void) {
// initialize the VGA display
display.begin();

display.delay(5000); // wait 5 seconds


display.clearDisplay(); // clear the screen buffer

display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("Hello, world!");
display.setTextColor(BLACK, WHITE);
display.println(3.141592);
display.setTextSize(2);
display.setTextColor(WHITE);
display.print("0x");
display.println(0xDEADBEEF, HEX);

display.setCursor(0, 40);
display.setTextSize(1);
display.print("Arduino VGA Example");
}

void loop() {
;
}

// end of code.

You might also like