Arduino Basic PC With TV Output

25,538

84

23

Introduction: Arduino Basic PC With TV Output

In this Instructables I will show how to build a retro 8-bit computer running BASIC, by means of two Arduino and few other components.

You can input the variables and the BASIC program with a PS2 keyboard, and the output is shown on a monitor with a text 47 columns x 29 rows of 8x8 pixels characters (B&W), a resolution similar or better than the Commodore 64, equal to 40 x 25 characters.

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.

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 video output thanks to the awsome MRETV library.

The idea to use one or more Arduino to create an old style PC running a dialect of Basic is not new, but so far there where some strong limitations in the output resolution. 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 has a much lower resolution. Furthermore in many of these projects special shields or hardware has to be build.

Here you need just two Arduino, a couple of diodes, few resistors and the connector for the PS2 keyboard and the monitor, as shown in the above picture.

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

TinyBasic Plus and MRETV work for elder - and different - Arduino IDE.

First download IDE 1.6.4 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.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 viariable 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 = 2400

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 taht 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;
  • of course 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 MRETV Library on the Second Arduino and Put Everything Together

The key point of this project is the existance of the awesome MRETV library. There is a dedicated Instructable where it is described in details.

It uses only two resistors and two diodes to generate full screen video, with a text resolution of 47 x 29 of 8x8 characters. As it says in the introduction, "video generation has been done before, but not like this. FULL DUPLEX serial still available while generating video". This allow to get the data from the "master" Arduino and show them on the monitor. In practise this second "slave" Arduino is used as a graphic interface!

Since MRETV works for IDE 1.6.6, download it from the Arduino official web page. Again, the best is to download it in .zip format and uncompress them on your PC. Click this link to download the Windows version.

Download then the MRETV library from this link.

Uncompress it and save the folder "MRETV" in: arduino-1.6.6\libraries

Finally download TVtext_slave.rar at the bottom of this page, uncompress it and upload in your Arduino slave.

If there are no error message, you can connect the RCA connector. You need the two diodes and the resistors of 1 kOhm and 300 Ohm, as shown in the schematic in this page.

At this point you can connect everything together.

The complete list of materials is:

  • two Arduino Uno Rev. 3 or two Arduino Nano 3.x (ATmega328)
  • two resistors 1 kOhm
  • one resistor 300 Ohm
  • two diodes 1n4148 (x2) or similar silicon switching diode
  • two RCA plug female (one for video, one - facultative - for audio)
  • a PS2 female connector
  • a breadboard and wires

The master Arduino sends the data to the slave trough the orange cable, i.e. master pin 1 (Tx) to slave pin 2 (Rx). If you need to re-upload some code, you should disconnect this cable first.

Connect then the slave arduino to a 5V power supply, the RCA cable to the TV and the keyboard to the PS2, and you should now see the code to your TV!

The functions of this Basic dialect are described in details in its homepage (see link in step 2). With the commands "esave" and "eload" you can save one Basic program in the EEPROM. This program is run by default each time you reset the master Arduino. To delete it you can use the command "eformat".

One of the most important features of this program is that you can still drive the master Arduino I/O with dedicated Basic commands, such as

  • DWRITE pin,value - set pin with a value (HIGH,HI,LOW,LO)
  • AWRITE pin,value - set pin with analog value (pwm) 0..255
  • DREAD( pin ) - get the value of the pin
  • AREAD( analogPin ) - get the value of the analog pin

Thus you can write a program in Basic that drives some hardware, save it in the EEPROM and then running it automatically just resetting the Arduino.

Step 4: Optional: Using a PCB

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

You can use two female header strips with 15 holes for the video output Arduino, while for the master I suggest to use four strips. In this way you can use the external ones to insert the contacts of your project componets.

I also added in the center to leftover strips, one conncted to 5 V and the other for GND.

Finally, in the .rar file, you can find the masks to etch a coppered board.

Step 5: Final Comments and Acknowledgments

This project could not have been done without the MRETV library. Thus my main acknowledgment goes to his author, which uses the acronym Mr E.

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: it is easier to build that it may seem at the first sight. My main problems have been with the Arduino IDE compatibilities. 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.

1 Person Made This Project!

Recommendations

  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • Block Code Contest

    Block Code Contest
  • Cold Challenge

    Cold Challenge

23 Comments

0
NGX
NGX

1 year ago

Code can't fit on arduino

0
Rob Cai
Rob Cai

Reply 1 year ago

yes it can

0
NGX
NGX

Reply 1 year ago

Got it to work by removing the sd part as i wont use sd cards, how do i store programs to eeprom?

0
Rob Cai
Rob Cai

Reply 1 year ago

the commands are esave and eload

for instance esave filename.bas
if you save a program with the name "autorun.bas" it will be executed automatically at the start. This is a bit risky, if your program cannot be stopped you will need to reflash the arduino. For instance a program such as

10 goto 10

saved in the eeprom with the name autorun.bas will get your arduino stuck.
trl+break does not work (if a remember correctly).

Other useful command for the eeprom are:

  • EFORMAT - clears the EEProm memory
  • ELOAD - load the program in from EEProm
  • ESAVE - save the current program to the EEProm
  • ELIST - print out the contents of EEProm
  • ECHAIN - load the program from EEProm and run it
see Tiny Basic Plus page for more details.
0
TheuTrich
TheuTrich

Question 1 year ago

can i use arduino mega adk instead your arduino ?
thanks.

0
VishnuS94
VishnuS94

Question 1 year ago on Step 5

Do i need another arduino if i choose to use a display module instead of tv out?

0
kv_12
kv_12

Question 4 years ago

hello, im am trying to build this project, bet when i want to program the master arduino, the IDE says that there is not enough memory. the ide is set to the correct arduino and the correct processor. i find this quite weird if it does fit on yours and not on mine. if you know an awnser please email me at : dijkkc@gmail.com

1
Rob Cai
Rob Cai

Answer 4 years ago

Hi kv_12, 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.ino now

Doest it work?

As pointed out by robogeekinc there may be unnecessary libraries added.

0
might.be.sherwood
might.be.sherwood

Reply 2 years ago

This worked for me. Thanks for the tip, and the awesome project.

0
robogeekinc
robogeekinc

Answer 4 years ago

I believe this project is cool. I haven’t tried myself but based on experience i’d say first check as you are compiling make sure there is no unnecessary libraries added or compiled on top. This may be causing the additional space taken. Perhaps Try an older version IDE to see the difference

0
MatthewB92
MatthewB92

Question 3 years ago on Step 3

Excellent project - I’m currently building one using two Arduino Nanos. Just out of interest - why did you decide to use two separate Arduinos rather than use the MRETV library in your TinyBasicPlus sketch? The documentation in the MRETV Instructable suggests it can be used in existing sketches, and there appears to be enough space to do so.

0
swc.rainier
swc.rainier

Answer 3 years ago

This gives each sketch more memory to process either (master)-Basic Interpreter or (slave) MRETV video.

0
simaopintocorreia
simaopintocorreia

3 years ago

Hi .I have an hold B&W tv and it probaly goes to work on it .so ,I go to make this.

0
grjonjon
grjonjon

Question 3 years ago on Introduction

Great project! Thank you for this instructable. I'm one of those "8bit micros" and "BASIC programming" kids, now with kids of my own, and your instuctable just brought back the nostalgia of the 80's computers! I couldn't resist building it.
One suggestion/thought I have is about the power supply of the "master" Arduino:
In the circuit you provide, you're applying power to the mini USB socket of the "slave" Arduino and, in turn, connect the +5V output of the "slave" to the Vin pin of the "master".
Taking into account that Vin on the "master" requires a voltage greater than 5V for proper voltage stabilization, wouldn't it make sense to, instead, connect the +5v pins of the two Arduinos together? That way, the "slave" gets the initial power via USB and then provides 5V straight to the "master's" +5V pin. Since the power requirements of both boards are low, that is safe. Also, one can connect USB power to either ONE of the Arduinos with no difference.
Actually, I chose to make that connection in my own realization of this project. Arduinos look happy enough with their power supplies and everything is working properly.
Thank you for this great project!

IMG_20190406_094647wTexts.jpgIMG_20190319_195008.jpgIMG_20190319_194742.jpgIMG_20190319_194847.jpg
0
Rob Cai
Rob Cai

Answer 3 years ago

Dear grjonjon, thank you for your comment and the suggestion. You are right, It is probaly better to connect the +5V as you did. Thank you also for posting the pictures of your realization!

0
Rodrigocml
Rodrigocml

Question 3 years ago

Great project, thanks. I decided to build this and hook up on a 70's tv using an RF modulator, looks nice and retro now, I will also try to build a reasonable retro case for it. I have a doubt about the SD card, I saw in the tinyBasic instructions that it supports SD card so do I just connect the SD module in the default pins (10 to 13) and it will work?

0
Rob Cai
Rob Cai

Answer 3 years ago

I do not know, but if you try let me kindly know if it works. I plan to buy a SD card module as well...

0
fegauneg
fegauneg

Question 3 years ago

How to delete last char I typed?

0
Drew BASIC
Drew BASIC

4 years ago

can you make a pcb one for me?

0
mcfly490
mcfly490

Question 4 years ago

es posible agregar un lector de memorias sd?