Arduino Basic PC With VGA Output

61,268

284

74

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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.

3 People Made This Project!

Recommendations

  • Magnets Challenge

    Magnets Challenge
  • Raspberry Pi Contest 2020

    Raspberry Pi Contest 2020
  • Wearables Contest

    Wearables Contest

74 Discussions

0
samcha95
samcha95

21 days ago

Hello, I love your project.
Would it be possible to add a third Arduino nano for more power and put sound, and an SD card to save the data (import / export of stored information)?
And have more RAM with additional SRAM memory?
Are you planning to further improve your computer?

I would like to make a computer from the 80s like the C64 and to program nice video games on it.

thank you.
and sorry for my english, i'm french :-p

0
Rob Cai
Rob Cai

Reply 19 days ago

Hi, thank you,
I am glad you like this project.
I think it should be possible to add sound and an SD for storage (eventually without adding a third Arduino), but I am not planning to further improve this "computer".
The main reason is that, as it is now, tinyBasic does not support any graphics and advanced math with floating or long integers.
For your curiosity, you can have a nice VIC 20 clone + games with this cheap board: TTGO VGA32 V1.2, which costs less than three Arduino nano. You can see the result following this link.

0
samcha95
samcha95

Reply 19 days ago

thank you for your reply. I had already seen this card actually.
good luck poyr your pretty project.
you have my support :-)

0
jer502
jer502

Question 7 weeks ago

I’m getting this “not enough memory" error
Looks like this was already addressed but it's still not working for me. Thanks!

Edit: I need to read more. I do have multiple versions of the IDE. I'll make sure I don't have it in the newer version tonight..One thing that's not clear to me is, Do I delete the other library folders in the libraries folder on 1.6.4 or leave them? I don't think but a comment suggested otherwise.

Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Nano, ATmega328"
Sketch uses 14,036 bytes (45%) of program storage space. Maximum is 30,720 bytes.
Global variables use 2,129 bytes (103%) of dynamic memory, leaving -81 bytes for local variables. Maximum is 2,048 bytes.
processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#si... for tips on reducing your footprint.
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.build(Sketch.java:1137)
at processing.app.Editor$BuildHandler.run(Editor.java:2032)
at java.lang.Thread.run(Thread.java:745)
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#si... for tips on reducing your footprint.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

0
Rob Cai
Rob Cai

Answer 6 weeks ago

Dear jer502,
do you have this error when uploading the "master" Arduino with TinyBasic, or the "slave" one with the VGAx library? In the latter case, there is a chance that the error is due to a VGAx library update to make it compatible with Arduino Mega. I included (as a .rar file) the vgax-master folder with the library I am using on my PC. Find it at the end of step 3. Let me kindly know if this works.

0
jer502
jer502

Reply 5 weeks ago

Rob,
No it’s the master that I’m getting the error on. I haven’t even tried the VGA nano. Tried somethings a little bit yesterday but no luck. Hopefully I’ll have more time to tinker in the coming weeks.

0
KushagraK7
KushagraK7

Question 6 months ago

Will it work if I connect the Arduino board to an HDMI input TV using a VGA to HDMI convertor?

0
mikolaj.olszowy
mikolaj.olszowy

Answer 6 weeks ago

Yes, it will work if you connect everything up and cables are not damaged

0
Rob Cai
Rob Cai

Answer 6 months ago

Hi KushagraK7, yes I believe it should work!

0
KushagraK7
KushagraK7

Reply 6 months ago

Thanks a lot! I'll try it.

0
DennisH159
DennisH159

Answer 8 weeks ago

#define ENABLE_FILEIO 1
//#undef ENABLE_FILEIO

0
paF2208
paF2208

4 months ago

Hi Rob! It's me again :P. Now I can load code TinyBasicPlus_PS2_VGAx in Arduino but on check step IDE give me this error (screenshot). Which variables I can comment or delete frome code?

Снимок экрана (478).png
0
DennisH159
DennisH159

Reply 8 weeks ago

-Use Arduino IDE 1.8.10
-Make sure to set Tools->Processor to AtMega 328.

0
Rob Cai
Rob Cai

Reply 4 months ago

Hi paF2208,
are you sure you are using exactly the PS2Keyboard.rar library reported here in step 1?
This library has little modifications compared to the original one.
Make sure you are using this version. Please note that if you have different versions installed on your HD, the Arduino IDE may use another one (although it should give you a warning about multiple versions detected).

0
paF2208
paF2208

Reply 4 months ago

Yes. Now I downloade your library and IDE gives me it error again. Can you send me your library please?

0
Rob Cai
Rob Cai

Reply 4 months ago

I have re-checked and I upload
  • TinyBasicPlus_PS2_VGAx.ino
  • VGAx-PC.ino
from two arduino IDE 1.6.4 with different libraries configuration.
For TinyBasicPlus_PS2_VGAx.ino I run a IDE (directly from arduino.exe) were the only library present is the folder “PS2Keyboard” you can find here.
For VGAx-PC.ino I use a standard IDE installation with all the provided libraries + the VGAx one.
0
paF2208
paF2208

Reply 4 months ago

Thank you very much! I deleted all libraries and sketch is uploaded successful! When I and my teacher made this project I note you!

0
simaopintocorreia
simaopintocorreia

Question 4 months ago

My IDE goes in error and say this :

Arduino: 1.6.4 (Windows XP), Placa:"Arduino Uno"
Opções de compilação alteradas, compilando tudo
O rascunho usa 14.036 bytes (43%) do espaço de armazenamento do programa. O máximo é 32.256 bytes.
Variáveis globais usam 2.129 bytes (103%) de memória dinâmica, restando -81 bytes para variáveis locais. O maximo é 2.048 bytes.
processing.app.debug.RunnerException: Memória insuficiente: veja http://www.arduino.cc/en/Guide/Troubleshooting#size para sugestões sobre como reduzir a sua pegada.
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)
Memória insuficiente: veja http://www.arduino.cc/en/Guide/Troubleshooting#size para sugestões sobre como reduzir a sua pegada.
Este relatório teria mais informação com
"Mostrar output verboso durante a compilação"
ativo em Ficheiro > Preferências

0
Rob Cai
Rob Cai

Answer 4 months ago

Hi simaopintocorreia,
are you sure you are using exactly the PS2Keyboard.rar library reported here in step 1?
This library has little modifications compared to the original one.
Make
sure you are using this version. Please note that if you have different
versions installed on your HD, the Arduino IDE may use another one
(although it should give you a warning about multiple versions
detected).