Arduino Basic PC With VGA Output

46,543

258

29

In my previous Instructable I have shown how to build a retro 8-bit computer running BASIC, by means of two Arduino, and with an output signal in B&W for a TV screen.

Now I will show how to build the same computer, but with the output signal in color for a VGA monitor!

You can input the variables and the BASIC program with a PS2 keyboard, and it generates the output for a VGA monitor with a text resolution of 24 columns x 10 rows of 5x6 pixels characters, in four colors. You can see it in action in the upper video. The program can then be saved on the Arduino EEPROM, and you can still control the I/O pins directly via Basic dedicated commands.

This project can also be used to print simple text messages on the monitor, as shown in the third picture in this page.

One Arduino is the "master", and it runs Tiny Basic Plus, a C implementation of Tiny Basic, with a focus on support for Arduino. It also control a PS2 keyboard. The output is then sent via the serial port to the second Arduino which generates the VGA output thanks to the VGAx library.

The idea to use one or more Arduino to create an old style PC running a dialect of Basic is not new but, as far as I know, none of them has a color output. In some projects available on the net, people used LCD displays, while in others, to allow the use of monitors, it has been used the TVout library, which is B&W. Furthermore in many of these projects special shields or hardware has to be build. Here you need just two Arduino, few resistors and the connector for the PS2 keyboard and the monitor, as shown in the above pictures.

Step 1: Build the Arduino Master With TinyBasic and PS2 Keyboard

TinyBasic Plus and the VGAx library work for Arduino IDE 1.6.4.

First download it from the Arduino official web page. If you have a newer versions on your PC, the best is to download it in .zip format and uncompress them on your PC. Click this link to download the Windows version.

You need then the PS2keyboard library. You can find it at the bottom of this page. Just uncompress it and copy the PS2keyboard folder in: arduino-1.6.4\libraries

Finally, in this page, download the file: TinyBasicPlus_PS2_VGAx.ino, uncompress and upload it on your Arduino.

This is a variation of the standard TinyBasic Plus where i have added the PS2 library and modified the code to accept the variables from it.

More details on TiniBasic Plus and tutorials can be found at this link.

If there are no problems, and compatibility issues, Tiny Basic is already running. You can test it trough a serial monitor in your PC. For this purpose I use PuTTY, but many other programs are available.

You have to set the correct COM port (it is the same you find in the Arduino IDE) and baud rate = 4800

Here you can already test some program in Basic just by typing them with your PC keyboard (NB later on I will show how to connect the PS2 keyboard directly to the Arduino).

Try for instance:

10 PRINT "Hello, World!"

20 GOTO 10

RUN

You can then stop the infinite loop just by typing ctrl+c.

Note that this combination will not work for the PS2 keyboard.

In the next step I will show how to connect the PS2 keyboard to Arduino.

Step 2: Connect the PS2 Keyboard to the Master Arduino

I got all the informations and library from this Instructable.

Essentially you need to connect the folowing four pins:

  • keyboard Data to Arduino pin 8,
  • keyboard IRQ (clock) to Arduino pin 3;
  • you need to connenct GND and +5V as well.

I got an old PS2 female connector from a broken PC motherboard. You can simply unsold it with a heat gun.

In the picture shown in this step, you can find the function of the needed pins of the PS2 connector.

Step 3: Upload the VGAx Library and Code on the Second Arduino and Put Everything Together

First download VGAx-PC.ino code at the bottom of this page and copy it on your PC in a directory with the same name.

Download the VGAx library from this link on GitHub. The easiest way is to copy it in the Arduino software subfolder named "libraries", to be immediately recognized.

IMPORTANT: this library works for Arduno IDE 1.6.4 but it is not fully compatible with elder or newer versions.

Upload the VGAx-PC.ino in your second Arduino board (I tested it for the Nano version but the Uno should work as well).

A warning for low available memory is normal. If you do not have other errors everything is ok and you can immediately start to build your own 8-bit PC.

For this you need:

  • two Arduino Uno Rev. 3 or two Arduino Nano 3.x (ATmega328)
  • a DSUB15 Connector, i.e. a VGA female connector or a VGA cable to be cut.
  • resistors: 2 x 68 Ohm and 2 x 470 Ohm
  • a PS2 female connector
  • wires
  • facultative: a breadboard or a strip board

The schematic is reported at the top of this step. An example of a finished “console” is shown in the introductive step.

Step 4: Optional: Using a PCB

You can also build this Basic VGA PC using a small PCB. You can take inspiration from the pictures in this step or you can even print your own board.

I used two female header strips with 15 holes for the video output Arduino, while for the master I used two strips with doble holes. In this way I can use the external ones to insert the contacts of other projects componets, that can be driven directly with Basic code. I also added in the center to leftover strips, one conncted to 5 V and the other for GND.

Step 5: Final Comments and Acknowledgments

My main aknowledgement goes to Sandro Maffiodo aka Smaffer, the creator of the awesome VGAx library.

Many thanks also to the authors of TinyBasic Plus:

  • Tiny Basic 68k - Gordon Brandly
  • Arduino Basic / Tiny Basic C - Michael Field
  • Tiny Basic Plus - Scott Lawrence

Thanks also to "djsadeepa", the author of the Instructable for the connection of the PS2 keyboard.

To all the people interested in this project: if you have troubles, do not hesitate to ask suggestions in the comments.

If you succeed, please write a comment too or share a picture of the device you build.

Share

Recommendations

  • Tape Contest

    Tape Contest
  • Trash to Treasure

    Trash to Treasure
  • Arduino Contest 2019

    Arduino Contest 2019

29 Discussions

0
None
divyansh1

Question 2 days ago

Hey cool project I'm trying to upload the Tiny basic on main arduino uno but it says not enough memory, please HELP!!

0
None
Billd39ET

13 days ago

Hi , great project, thnx!

I made it and it works, but the VGA output is RED only - how did you get colours?

What are your VGA to Uno pin connections - its not clear in the image.

thnx
billd

6 replies
0
None
Rob CaiBilld39ET

Reply 12 days ago

Hi Billd39ET,
to change color, you need to press the caracter "&" in your PS2
keyboard. Note that in the Tiny basic code "&" is omitted, but the
color is cycled to the next one (red, gree, yellow, and so on).

By the way, if you see all red characters from the beginning, there must be something wrong in the VGA port connection. The correct ones are:
Arduino pin D6 to VGA pin 1 - RED (through a 470 Ohm resistor)
D7 to VGA pin 2 - GREEN (trough another 470 Ohm resistor as well).
D3 to VGA pin 13 - Hsync (through 68 Ohm)
D9 to VGA pin 14 - Vsync (through another 68 Ohm)
GND to VGA pin 5, 6,7,8, and 10
For more details see https://github.com/smaffer/vgax

Please, let me know if it works.



0
None
Billd39ETRob Cai

Reply 12 days ago

Hi Rob, I made a custom cable, eliminated as much of the noise sources as I could, still pretty bad interference on the display. I've tried two different displays, changed as many of the display settings as I could.

Still noisy output, any ideas?

EDIT: I've found a number of posts that mention this jitter, and the fix which is in the VGAX.h library . . . but I'm still seeing it - any ideas?

thnx
billd

VGA04.jpgVGA03.jpg
0
None
Rob CaiBilld39ET

Reply 11 days ago

Hi Billd39ET. I had exactly the same problem at the beginning. It is not a "noise" but a glitch or bug created by a wrong arduino IDE. TinyBasic Plus and the VGAx library work only for Arduino IDE 1.6.4.

0
None
Billd39ETRob Cai

Reply 11 days ago

Hi Mate,

Compiled on 1.6.4 . . . works perfect. Annoying but good to know the issue.

thnx
billd

IMG_8208.JPEG
0
None
Billd39ETRob Cai

Reply 11 days ago

Thnx, I thought that would be the case . . . was trying to avoid having to install the older IDE, usually breaks links to libraries and python does not like it at all!

cul
billd

0
None
Billd39ETRob Cai

Reply 12 days ago

Thnx Rob, I had the correct pins, but had flipped the resistor values for GREEN, its working with all colours now, thnx. There's a lot of noise on the display, but I think that's because I'm using a lot of hook-up wires and breadboard. Now that I have it working I'll make up a direct connector with an old VGA cable and eliminate a lot of the connectors..
thnx agin
billd

VGA01.jpgVGA02.jpg
0
None
AhmedE526

Question 11 months ago

What Should i do if i wanna use usb keyboard ? any thing will change ?

2 answers
0
None
Rob CaiAhmedE526

Answer 11 months ago

I do not think it is possible (at least in an easy way!). I already tried an USB to PS2 converted and it does not work!

1
None
AdamM329

Question 5 months ago

Any way to add storage device (SD card, USB flash etc...) to save your BASIC code?

0
None
AhmedE526

11 months ago

What Should i do if i wanna use usb keyboard ? any thing will change ?

0
None
PhilInst

Question 1 year ago

Using Arduino IDE 1.6.4 (In W10pro 64 v1709)

Initially tried to compile for Arduno Pro/Mini (Later UNO)
Had error: In file included from TinyBasicPlus_PS2_VGAx.ino:170:0:
E:\Development\Arduino\ArduinoProx2_BASICVGA\arduino-1.6.4-windows\arduino-1.6.4\libraries\PS2Keyboard/PS2Keyboard.h:32:22: fatal error: WProgram.h: No such file or directory
#include "WProgram.h"

To get it to compile, in 'PS2Keyboard.h' had to change:
#include "WProgram.h"
to
#include "Arduino.h"
(From a Google search)

==========================================
Then it compiled but ran out of memory (-81 bytes)

In 'TinyBasicPlus_PS2_VGAx' changed:
#define kRamSize (RAMEND - 1160 - kRamFileIO - kRamTones)
to
#define kRamSize (RAMEND - 1242 - kRamFileIO - kRamTones)
(Now compiles leaving 1 byte free - with warnings)
===========================================

Downloaded to a ATmega328-PU on UNO board
Tried the test program shown with Putty and RealTerm (USB COM6 4800Bd)
The board seemed to receive data but nothing transmitted back.
Any suggestions?

2 answers
0
None
PhilInstPhilInst

Answer 1 year ago

Yes it does. (had to delete/reinstall 1.6.4 IDE and contents and re-modify the #include "WProgram.h" to "Arduino.h" in PS2Keyboard.h. I did not have to modify KRamSize this time) Thankyou very much - it looks like a nice project. I'll be trying the 'pro boards when I get them. VGA next.

BasicOK.bmp
0
None
Rob CaiPhilInst

Answer 1 year ago

Try the following:

1) rename the folder libraries in the Arduino IDE 1.6.4 (for instance libraries.old)

2) re-create the folder libraries and copy there only the folder PS2Keyboard with all its content you got fom PS2Keyboard.rar of step 1.

3) Try to compile TinyBasicPlus_PS2_VGAx.ino now

Doest it work?

PS I guess that this application does not work for Arduino Pro/Mini.

0
None
dfortin

1 year ago

Would it be possible to have uSD over I2C in order to increase the effective memory?

1 reply
0
None
Rob Caidfortin

Reply 1 year ago

I think it is possible but I did not tried it yet.

0
None
AndreasZ6

Question 1 year ago

What's do to if first letter is not visible on VGA screen? Does change IDE Version from 1.8.1 to 1.6.4 help or can I make some adjustments in code for syncron impulse? As described the output is very bad with IDE 1.8.1. I changed your VGAx-PC.ino code to scroll the screen if it is filled complete. But a need a little time yet to optimzed it.