Arduino Basic PC With VGA Output

49,640

264

49

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.

Share

Recommendations

  • Fandom Contest

    Fandom Contest
  • Classroom Science Contest

    Classroom Science Contest
  • Frozen Treats Challenge

    Frozen Treats Challenge

49 Discussions

0
None
Yves-rene

17 hours ago

Hi. The First Project with Color Output. I love it :) very good work.
Is it possible to get Video out (via cinch) instead of the vga Output? Did this Basic Interpreter include graphical Commands, like draw line or circle? Many thanks :)

0
None
divyansh1

Question 2 months ago

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

2 answers
0
None
Rob Caidivyansh1

Answer 8 weeks ago

Hi, a warning for low available memory is normal. Make sure you use the correct Arduino IDE 1.6.4

0
None
divyansh1Rob Cai

Reply 17 days ago

I am using 1.6.4 i have no other IDE's, I have checked if the IDE is using that library only, I have not deleted any extra libraries so HELP!! It says not enough memory ,it says global variables use 105% of the memory.This is while uploading Tiny basic PS2 code

0
None
paF2208

Question 5 weeks ago on Step 3

Hi Rob! Can you send me scheme in higher than quality please? Cause I can't see pin names on this scheme(
And second question: when I upload PS/2 Keyboard code in Arduino Nano, it give me error like a not enough memory. What kind of code parts can I remove? I using Arduino IDE 1.6.4.

8 answers
0
None
Rob CaipaF2208

Answer 5 weeks ago

Here it is the scheme.
About the second question: a warning - not an error! - for low available memory is normal. Is this the case?

Arduino VGA PC_bb.pngArduino VGA PC_bb.jpg
0
None
paF2208Rob Cai

Reply 5 weeks ago

This case is fits for VGA.ino, but in PS/2.ino code doesn't upload in Nano and write error like compile error: a not enough memory. If you doesn't understand it, I can give you screenshots with this error.

0
None
Rob CaipaF2208

Reply 5 weeks ago

You are right, the low memory warning is for the upload of VGAx-PC.ino in the second Arduino (step 3), my mistake.
So, if I understand correctly, you have the error when you upload TinyBasicPlus_PS2_VGAx.ino on the first Arduino (Step 2), isn't it?

If you have more than one Arduino IDE installed on your PC, it could be that it reads a library from another IDE, where you may have a sligtly different version to respect the one you have to download here in step 2 (PS2Keyboard.rar).
If you scroll the messages you get after the upload, you can eventually find something as:
"more than one PS2Keyboard.h found, used the version in the folder c:/***/***/"

Check that the IDE is using the correct library!


0
None
paF2208Rob Cai

Reply 5 weeks ago

Now I have this error:
C:\Users\A4F7~1\AppData\Local\Temp\build4291926532138477575.tmp/core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:40: undefined reference to `setup'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status
Compile error

Now I'm using only 1 library from C:\Program Files (x86)\Arduino\libraries and deleted second library from C:\Users\USERNAME\Documents\Arduino\libraries

0
None
Rob CaipaF2208

Reply 5 weeks ago

It looks like you deleted too many libraries...
Restore them and just delete the PS2keyboard folder and replace with the one in step 2.

0
None
paF2208Rob Cai

Reply 5 weeks ago

I reinstalled IDE 1.6.4 and droped PS/2keyboard lib to libraries folder, but it doesn't give me any result (this error again)...

0
None
Rob CaipaF2208

Reply 4 weeks ago

Hi, I added the same schematic, with a better resolution, at the bottom of step 3, in a compressed file. I am sorry that you have this issue when uploading the code of step 1, I suppose it is a matter of libraries...

0
None
paF2208Rob Cai

Reply 5 weeks ago

I don't know what's this. Next I will try upload code from other computer. I'm sorry, but can you describe me in more detail how to connect contacts on Nano and other details? I don't see pin names again, xd

0
None
abdaborasheed

Question 7 weeks ago

that very good project but dread and any one parameter instruction do not work the result is "what?" what is the solution or what is the right syntax for thos instruction

5 answers
0
None
Rob Caiabdaborasheed

Answer 7 weeks ago

This may be the case if there is a sintax error in your code.
Try first with simple instruction, such as:
print "Hallo!"
or
10 a=5
20 b=a*a
30 print b
run

Do they work?
if not, can you upload a picture of two?

0
None
abdaborasheedRob Cai

Reply 7 weeks ago

all of them work fine but any instruction with one parameter related with arduino board like DREAD and AREAD do not work but DWRITE and AWRITE work fine the syntax i wrote "DREAD pinnumber" is that true syntax or not

0
None
Rob Caiabdaborasheed

Reply 7 weeks ago

ah ok, I misuderstood the question.
the sintax is (for instance):
a=dread(pinnumber)

0
None
abdaborasheedRob Cai

Reply 7 weeks ago

thank you very much that what i am looking for.
i am thinking if we can merge both programs tinyBasic and vga display on one arduino board i have arduino mega 2560 and i reduce memory usage to 50% in tinyBasic program by reduce "program" matrix size and reduce memory usage to 30% in vga program by making resolution 120x90 ,so can we combine thes two programs in one program if so what is the final result

0
None
Rob Caiabdaborasheed

Reply 7 weeks ago

Yes, I think it is possible. I am doing the same thing on an ESP32. I have already a working version with 640x350 pixels of resolution on the VGA and 14K of free memory for the Basic code. I just need to refine some details and I will write an Instructable with it...

0
None
RuralEngineer

Question 7 weeks ago

Hi, This is a fantastic project. Thank-you very much for sharing... I'm just getting the parts list ordered to have a go at building one. I have a question that others have previously asked. Do you have any plans to develop a SD card module which could be hooked up to the main nano to save and load programs? or is there anyway to load programs from file? I'm planning on building this anyway, it's too cool not to!