[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Electronics
. -> [Folder]  Microprocessors
. . -> [Subject]  Library for MicroVGA adapter
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Library for MicroVGA adapter

Postings by administrators only.

[Refresh] Refresh page

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Tue 17 Apr 2012 03:39 AM (UTC)

Amended on Tue 17 Apr 2012 09:59 PM (UTC) by Nick Gammon

I recently got a MicroVGA output device for the Arduino:



Using SPI you can send text to a normal VGA monitor (most of us will have one of them lying around).

Example output ...

To help use it I wrote a small library. First, to connect:


1 GND     Arduino GND
2 +5V     Arduino +5V
3 +3V3 output NOT CONNECTED
4 /SS     Arduino Digital 10
5 SCK     Arduino Digital 13
6 /RDY    Arduino Digital 9
7 MISO    Arduino Digital 12
8 MOSI    Arduino Digital 11 

Switch to SPI mode

Plug in a PS2 keyboard (it only goes into one socket), power up the device, and short the "setup" pad (on the edge near the keyboard socket, see photo) with a screwdriver. It should enter "setup" mode.

  • Select "Communication -> SPI Mode"
  • Hit Enter
  • (Note, if you go back in 1000000 baud is still selected, that is the default, not the current mode)
  • Select "Save settings"
  • Wait for confirmation
  • Power device off (unplug Arduino from power)


Download from:


Unzip contents into your "libraries" folder.

Sketch showing output

#include <SPI.h>
#include "uvga.h"

uVGA uvga;

void setup ()
  uvga.begin ();
  uvga.clrscr ();
  uvga.println ("uVGA test.");
  }  // end of setup
void loop ()
  for (int color = BLACK; color <= WHITE; color++)
    uvga.textcolor (color);
    uvga.print ("Color: ");
    uvga.println (color);
    uvga.println (micros ());
    delay (1000);
  }  // end of loop

The class is based on the Stream class which lets you do the usual things you can with stuff like Serial. That is print, println, test if input is available, and so on.

You can also call these functions to do useful things with the screen like clearing it, changing colours and so on:

  • clrscr
  • clreol
  • cursoron
  • cursoroff
  • textcolor
  • textbackground
  • textattr
  • gotoxy

Sketch showing input

// Demonstrates text input

#include <SPI.h>
#include "uvga.h"

uVGA uvga;

void setup ()
  uvga.begin ();
  uvga.clrscr ();
  uvga.println ("uVGA input test.");
  }  // end of setup
 // callback handler for function keys 
boolean fkey (const int key)
  uvga.print ("Function key: ");
  uvga.print (key, HEX);
  uvga.println (" pressed.");
  if (key == KB_ESC)
    return true;
  return false;

// get user input  
void loop ()
  char buf [20];

  uvga.textcolor (WHITE);
  uvga.print ("Enter something ... ");
  if (uvga.getline (buf, sizeof buf, fkey))
    uvga.println ("Cancelled");
  uvga.textcolor (RED);
  uvga.print ("You entered: ");
  uvga.println (buf);
  uvga.println ();
  }  // end of loop

The getline function lets you query for input. This is a blocking call. If you want to do it non-blocking just use uvga.available() and put things into a buffer (which is what getline does).

You can optionally supply a callback function to handle things like F3 being pressed, or the ESC key.

Sketch showing cursor positioning

// gotoxy test

#include <SPI.h>
#include "uvga.h"

uVGA uvga;

void setup ()
  uvga.begin ();
  }  // end of setup
void loop ()
  uvga.clrscr ();
  uvga.cursoroff ();
  for (int x = 1; x < 80; x += 10)
    uvga.textcolor (x / 10 + 8);  
    if (x == 1)
      uvga.textcolor (GREEN);
    for (int y = 1; y <= 24; y++)
      uvga.gotoxy (x, y);
      uvga.print (x);
      uvga.print (",");
      uvga.print (y);
  delay (5000);
  }  // end of loop

The above sketch demonstrates the gotoxy function. With that you can move the cursor around on the screen.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


Postings by administrators only.

[Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]