Pages: [1]   Go Down
Author Topic: Interfacing with the microVGA  (Read 451 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone,
I recently got myself a microVGA but I can't seem to get it to work completely.
It will start up properly, showing the greenish header with yellow text.
Though when I upload the example menu or tetris sketch, it doesn't do anything. (I've already changed the communication setting to SPI)
When I upload the first test sketch, from the microVGA website, it will sometimes display the proper character 'U' and sometimes it will displays '¬'.
If I disconnect the arduino from USB and reconnect it again, there is a 50% chance that the character displaying sketch will work properly or not.

If anyone has had anything similar or knows a solution please post it  smiley

Edit:
RoyK also seems to be experiencing this problem
« Last Edit: December 05, 2009, 01:45:05 pm by ProDigity » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since nobody replied to my topic, I'll assume that nobody got it to work.
(Or that nobody has one due to it's bad arduino reviews)
Anyway, after a few days of trial and error I gave up on SPI and chose the NewSoftSerial library to do my bidding and it worked!
I even managed to get the native MicroVGA demos to work by frankenstein'ing newsoftserial together with the microvga libraries.
(but I won't be showing that here because people would probably shoot me for its uglyness)
So without further ado, here's a working example:
Code:
// MicroVGA mini-guide by Prodigity
//     _______________
//    |KEY  VGA  S-VIDEO
//    |
//    |
//    |_|_|_|_|_|_|_|_
//      1 2 3 4 5 6 ......
//
// Connect 1 to gnd
// Connect 2 to 5V
// We don't need 3, it supplies 3v3
// Connect 4 to gnd (
// Connect 5 to OutputPin (We chose pin 3 on the arduino)
// Connect 6 to InputPin (We chose pin 2 on the arduino)

// This library handles all of our output and input. (V9 should be able to handle "57.6K baud on a 16MHz processor and 31.25K baud at 8MHz")
#include <NewSoftSerial.h>

// This library allows us to store strings in the flash memory instead of the SRAM.
// This is necessary because the ascii image below is 80*25 chars big. (approx. 2 kilobyte)
// The SRAM on the Atmega168 is only 1 Kb, and trying to put more data on it than will fit
// will only cause problems. (as I've found out personally)
#include <avr/pgmspace.h>

// Customize these to your needs
#define BaudRate 38400
#define InputPin 2
#define OutputPin 3

NewSoftSerial mySerial(InputPin, OutputPin);

// Storing all the strings in flash. (25 strings each with a length of 80 characters)
// 25 by 80 is a convenient size because it's the amount of characters that will fit on one screen.
// Duck is copyright of AmyShortStuff. (http://xxheartofstonexx.deviantart.com/)
prog_char Duck_1[] PROGMEM  = "                                                                                ";
prog_char Duck_2[] PROGMEM  = "                                                                                ";
prog_char Duck_3[] PROGMEM  = "                             ,:===~:                                            ";
prog_char Duck_4[] PROGMEM  = "                           ,~========:                                          ";
prog_char Duck_5[] PROGMEM  = "                          ,============,                                        ";
prog_char Duck_6[] PROGMEM  = "                         ,=====~,:=====~           :~:                          ";
prog_char Duck_7[] PROGMEM  = "                         :====:    =====,       ,~=====,                        ";
prog_char Duck_8[] PROGMEM  = "                     ::, ~====,   ~=====    ,~=========:                        ";
prog_char Duck_9[] PROGMEM  = "                    ~====~=============, :~============~                        ";
prog_char Duck_10[] PROGMEM = "                    ~===================================,                       ";
prog_char Duck_11[] PROGMEM = "                     :========================~::=======~                       ";
prog_char Duck_12[] PROGMEM = "                       ,:~======================, :======                       ";
prog_char Duck_13[] PROGMEM = "                             ,==================~  ======                       ";
prog_char Duck_14[] PROGMEM = "                             :=================~   ~=====                       ";
prog_char Duck_15[] PROGMEM = "                            :==================~   ~====~                       ";
prog_char Duck_16[] PROGMEM = "                           ,=====~==============   =====:                       ";
prog_char Duck_17[] PROGMEM = "                           ,====~===============  ,=====                        ";
prog_char Duck_18[] PROGMEM = "                           ,=====~=============~  ~====:                        ";
prog_char Duck_19[] PROGMEM = "                            :=====~:~====~,,::,  ~====~                         ";
prog_char Duck_20[] PROGMEM = "                             :======:,         ,~=====,                         ";
prog_char Duck_21[] PROGMEM = "                              ,~=======~:::::~=======,                          ";
prog_char Duck_22[] PROGMEM = "                                ,==================:                            ";
prog_char Duck_23[] PROGMEM = "                                   :=============:                              ";
prog_char Duck_24[] PROGMEM = "                                      ,:~~~~~:,                                 ";
prog_char Duck_25[] PROGMEM = "                                                                                ";

// Define a array of pointers to our strings for easy access.
PROGMEM const char *string_table[] =
{  
  Duck_1,
  Duck_2,
  Duck_3,
  Duck_4,
  Duck_5,
  Duck_6,
  Duck_7,
  Duck_8,
  Duck_9,
  Duck_10,
  Duck_11,
  Duck_12,
  Duck_13,
  Duck_14,
  Duck_15,
  Duck_16,
  Duck_17,
  Duck_18,
  Duck_19,
  Duck_20,
  Duck_21,
  Duck_22,
  Duck_23,
  Duck_24,
  Duck_25,
};

// This needs to equal the biggest string you've stored in the flash memory. (They're all 80 atm)
char buffer[80];


void setup()  {
  mySerial.begin(BaudRate);
  delay(1000); // Give the microVGA the chance to 'warm up'.
  for (int i = 0; i < 25; i++) // Load every string from flash
  {
    for (int j = 0; j < 80; j++) // Print the characters one by one and skips the NULL character
    {
      strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i]))); // Copy a string from flash into our buffer in sram
      mySerial.print( buffer[j] ); // Print a character!
    }
  }
}

void loop() {
 char b;
 if (mySerial.available()) // Has the microVGA sent a character?
  {
    b = mySerial.read(); // Read the character
    mySerial.print(b); // Send it back (to be printed on the screen)
  }
 
}
Logged

Pages: [1]   Go Up
Jump to: