Arduino Basic PC With VGA Output

85,168

318

100

Introduction: Arduino Basic PC With VGA Output

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.

The same schematic, with an higher resolution, is reported in a compressed file at the bottom of this 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.

5 People Made This Project!

Recommendations

  • 3D Printed Student Design Challenge

    3D Printed Student Design Challenge
  • Organization Contest

    Organization Contest
  • Halloween Contest

    Halloween Contest

100 Comments

0
kszimo12345
kszimo12345

8 months ago

Hi. Can I use a uno and a mega?

0
Rob Cai
Rob Cai

Reply 8 months ago

I do not know. If you already have the mega, try to upload the code. If there are no error messages, there is a chance that it works.

0
kszimo12345
kszimo12345

Reply 8 months ago

Thank's for the reply, it didn't work, so I'm gonna get the right boards.

0
PlayFull_Pet1
PlayFull_Pet1

Reply 2 months ago

It acctauly dose! you should use a mega to run BASIC and the uno to run the video program. and you get a lot more memory using a mega.

0
kszimo12345
kszimo12345

Reply 2 months ago

Yeah I did get tiny basic to work, on the mega fine, although I couldn't get the boards to communicate, I might get back to this project and try to make it work one more time. Thanks for the reply.

0
PlayFull_Pet1
PlayFull_Pet1

Reply 7 weeks ago

If your using Elegoo boards, they have this annoying fault where on the female pin they have the pin function which is really nice, but on the boards the 2 pins for communicating with other arduinos are misslabeled, so if you have Elegoo, look on the silkscreen.

0
kszimo12345
kszimo12345

Reply 7 weeks ago

Thanks, for the info.

0
Rob Cai
Rob Cai

Reply 2 months ago

Hi, just for your info, I am working on a new Tiny Basic PC with and
ESP32 (cheaper than two Arduino nano) with a lot more features, as shown
here:
and here:

0
Rob Cai
Rob Cai

Reply 2 months ago

Hi, just for your info, I am working on a new Tiny Basic PC with and ESP32 (cheaper than two Arduino nano) with a lot more features, as shown here:
and here:


0
eudbriel
eudbriel

Question 11 months ago on Introduction

Rob, what books should I read to understand how you and your friends did this project, I mean, it's easy to follow your steps and use the programs and the libraries you used, but I think it's hard to create this programs, relate the VGA pins and Ps2 pins to arduino comprehend this. What books should I read to do this? To do what you and your friends made.

0
eudbriel
eudbriel

11 months ago

Hi,I tried to upload the program to the arduino Nano "master", and it said the board doesn't have enought memory. The arduino "slave" ( with the VGA conector ) hold it's program properly. What should I do?

Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Nano, ATmega328"
The sketch uses 14,036 bytes (45%) of storage space for programs. The maximum is 30,720 bytes.
Global variables use 2,129 bytes (103%) of dynamic memory, leaving -81 bytes for local variables. The maximum is 2,048 bytes.
processing.app.debug.RunnerException: Insufficient memory. See http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on how to reduce the size of your code.
at processing.app.debug.Compiler.size (Compiler.java:338)
at processing.app.debug.Compiler.build (Compiler.java:117)
at processing.app.Sketch.build (Sketch.java:1162)
at processing.app.Sketch.exportApplet (Sketch.java:1180)
at processing.app.Sketch.exportApplet (Sketch.java:1166)
at processing.app.Editor $ DefaultExportHandler.run (Editor.java:2487)
at java.lang.Thread.run (Thread.java:745)
Insufficient memory. See http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on how to reduce the size of your code.
This report should have more information
"Show verbose output during compilation"
enabled in File> Preferences.

0
Rob Cai
Rob Cai

Reply 11 months ago

just comment (or delete) the line 179:
#include <SD.h>
(you can add two "//" in front of it, i.e.
//#include <SD.h>
I just realized this library is missing in my IDE version...

0
eudbriel
eudbriel

Reply 11 months ago

Now the screen works properly and I can type things on the screen using the keyboard, but when I run a program it doesn't works, I tried to upload:
10 PRINT "Hello, World!"
20 GOTO 10
RUN
But when I wrote that nothing happens like if it was trying to run the program in a infinity loop, I could type anything and nothing happened in the screen.

0
eudbriel
eudbriel

Reply 11 months ago

I think it worked! I was able to send the program to the Atmega.

0
minhajuddin1
minhajuddin1

Question 11 months ago

can i do the same but run Python or C instead of basic

0
Rob Cai
Rob Cai

Reply 11 months ago

Nope! MicroPython requires minimum 128K of Flash + 8K of RAM, and smallest C distro are even larger. Tiny Basic Plus just fits by an inch in the Arduino memory (Flash 32k bytes, SRAM 2k bytes, EEPROM 1k byte).

0
VasilyM
VasilyM

11 months ago

Hi all!
I'm trying to figure out the circuit: the first thing that catches my eye is where and how the blue contact with the arduino goes to the VGA and the second: in the circuit, not all VGA contacts are connected to the GND ... I ask for help!
And more: What resistors can be used in terms of power?

23.PNG
0
JordiC27
JordiC27

1 year ago

Hi Rob, this is a fantastic project! Thanks a lot.

I did it and added some improvements and here's how to do them:
- I added a 9v battery. The + wire goes to a switch, and then to the VIN pin of the secondary arduino (the one than controls the VGA).
- Added a piezo speaker: the + goes to pin 5
- Led indicator of power on: the + of the led goes to a 220 ohm resistor, then to the 5V pin of the secondary arduino.
- Reset button: the button joins gnd with the RST pin of both arduinos
- SD card: as usual for arduino nano. CS pin goes to pin 10.

In the tinybasic .ino file you only have to activate the piezo buzzer option and the sd option. Your code also works with Arduino 1.8.1 (and I suppose that newer versions too). In the old arduino, it didn't work.

I have 2 issues:
1- Possibly because my keyboard is Spanish, the Backspace key is not read correctly. I need to change the code to support spanish keyboard. As it is not read correclty, it is like if it was not typed. So if I make a correction in a line I type, it gives syntax error always. Can someone check if this happens for you? For example, you type

print "helle"

and then delete the end e" and type print "hello", and it gives a syntax error for you? Mine does.

2- The TO in the for...next loop doesn't work. It gives a syntax error and tellls the line, saying "^o" instead of "to". I suspect it's because of the same keyboard problem. Does it happen for you?

Can you help me to know why this fails? Thanks!!

IMG_20200805_124948.jpg
0
Rob Cai
Rob Cai

Reply 1 year ago

Hi JordiC27, yes the backspece button does not work properly. It is not related to the keyboard but to the software itself. But the to in the for... next should work just fine.
For instance, the example below:

10 for i=1 to 3
20 ? i*i
30 next i


should give you:
1
4
9
OK

when executed...
Sorry for not beeing helpful, BTW your realization with the speaker, SD and wood box is super cool! I will try the SD for sure as soon as I have some time!

0
JordiC27
JordiC27

Reply 1 year ago

Thanks a lot Rob. Then I will see why it happens with the backspace. It is less annoying than the problem with the "to". I have checked that the same happens with all the keywords in the middle, like "abs".
For me the program gives a syntax error in 10, and says
syntax error 10 for i=o t^ 3
No idea why.
If I can't fix, I may try to create some kind of crappy basic that only uses commands with 1 parameter to replace the for and similar, but as a last resource.
Thanks for the compiments! The speaker is very fun to try the tone command. I have seen you can use values for tone from 100 to 8000 and it sounds good.
The sd also works, and adds a lot of usability.