This project began in a rainy summer 2021 in Corona lockdown when I started to write a BASIC interpreter for Arduino from scratch. The project was simple and mainly targeted for Arduino UNO and other small systems but has now outgrown this beginnings. This project is to show how one can build an entire standalone computer with it.
Read here for more on the BASIC interpreter design and how this project started: https://github.com/slviajero/tinybasic/wiki
The computer here is an Arduino DUE based home computer with a 7 inch 800*480 graphics display, printer support, SD card disk, a PS2 keyboard and a real time clock. It includes full Arduino I/O support and an easy way to access I2C devices from the BASIC language.
Details how on the build the computer and a few of the details are here https://github.com/slviajero/tinybasic/wiki/Projects:-4.-A-standalone-computer-with-a-TFT-screenUpdates
October 2022: with BASIC version 1.4.a USB keyboards are supported on DUE. Languages are English and German. No need for a PS2 keyboard any more.A word on selecting the display
Buying the right display can be a bit tricky. There are many on the market with varying quality of library support. I chose a 7 inch SSD1936 compatible 800*480 screen. It can be used with the UTFT library. To connect it to an Arduino Mega or DUE a shield is needed. DUE and Mega shields differ because of the different layout of the SPI pins in both Arduinos.
Best consult the UTFT library manual before buying a display.
There is one more important point when you use the TFT shield for DUEs. In the library folder of UTFT (UTFT/hardware/arm) you need to edit HW_ARM_defines.h and uncomment
#define CTE_DUE_SHIELD 1.
The TFT shield will cover the upper side of the Arduino completely. No additional wires can be connected easily. There are no prototype boards on the market that work with a shield. For this reason I soldered a few wires to the shield to get access to power.
The blue wire is GND, the white wire is +5V and the green wire is +3.3V. There wire can be connected to a breadboard at the base of the display to provide power for the keyboard and additional devices.
My DUE shield as an own SD card slot. An old 2 GB SD card formated with a FAT filesystem serves as mass storage.
Turning around the shield you see an important detail
DUE shields have a SPI connector in the middle of board. Unlike the MEGA 256 the SPI bus of a DUE cannot be accessed from pins 50-53. It is only reachable through the middle SPI connector. A MEGA shield will not work on a DUE.Prepare the Arduino
I use pins 8 and 9 to connect the PS2 keyboard, the second serial port for the printer and the I2C pins for the optional real time clock and other peripherals.
To get access to the pins without more soldering cables can be hooked up in the DUE before the shield is connected.
Pressing the DUE on the shield will hold the cables in place. This is not perfect electronics but it works.
Then plug DUE and shield to the backside of the display
If you want to connect a PS2 keyboard, continue reading here. For an USB keyboard, skip this section.
Solder wires on your PS2 sockets following the instructions on this page https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
If you use an Arduino MEGA 256 which is a 5V machine you are done after soldering. You can connect pin 8 of the Arduino to the clock pin of the keyboard socket and pin 9 to the data pin. Power for the keyboard comes from the GND and 5V soldered to the shield. Double check here as a wrong polarity of the power fries the keyboard.
With an Arduino DUE it would be advisable to use a level converters between keyboard and the Arduino PIN as the DUE is a 3.3V system.
The GND and +5V pins and the connectors of the PS2 socket are wired to the 5V side of the level converters while GND, 3.3V power and the two Arduino pins go to the 3.3V side. Best mount the level converter on a breadboard behind the screen.
A standard USB keyboard can be used on a DUE. Use second USB port for the keyboard. This is the lower one if the DUE is mounted like shown in the picture. You might need a USB keyboard connector.
Follow the instruction for USB in the instructions below.Upload the software
Load the UTFT library in your Arduino IDE from the website. Also make sure that you have the actual patched version of the PS2 library (see links below). If you plan to add a clock you should also download the uRTCLib.
Load the BASIC interpreter in the Arduino IDE. You will only need the sketch https://github.com/slviajero/tinybasic/tree/main/IoTBasic and the files hardware.h and basic.h. Next you need to open the file IoTBasic.ino and set and the language features.
#define BASICFULL #undef BASICINTEGER #undef BASICSIMPLE #undef BASICMINIMAL #undef BASICTINYWITHFLOAT
The you set the hardware features at the beginning of hardware-arduino.h. Look for the section
#undef UNOPLAIN #undef AVRLCD #undef WEMOSSHIELD #undef MEGASHIELD #undef TTGOVGA #define DUETFT #undef MEGATFT #undef NANOBOARD #undef MEGABOARD #undef UNOBOARD #undef ESP01BOARD #undef RP2040BOARD #undef RP2040BOARD2 #undef ESP32BOARD #undef MKR1010BOARD
Activate the DUETFT setting. Compile and upload to the Arduino DUE.
If you want to use a USB keyboard, activate
in addition to this.
Enjoy a fully featured 64kB BASIC home computer with graphics.
The output above is generated by this little program
10 CLS 15 I=0 20 X=RND (800) 30 Y=RND (480) 40 R0=RND (40) 42 R=RND (255):G=RND (255):B=RND (255) 43 COLOR R,G,B 50 FCIRCLE X,Y,R0 55 @X=1:@Y=1:PRINT #5;I; 56 I=I+1 60 DELAY 100 70 GOTO 20
More info on the basics of BASIC for Arduino can be found in this tutorial.Software for this computer from my repo
There is a mini manual for the BASIC interpreter in my wiki.Libraries used
PS2 keyboard: https://github.com/PaulStoffregen/PS2Keyboard
UTFT library: http://www.rinkydinkelectronics.com/library.php?id=51Costs
The most expensive components is the TFT display with a price of 110 Euros followed by the genuine Arduino DUE for 35 Euros. Shield, level converters, cabling, plugs and breadboards may cost around 20 Euros and an old PS2 keyboard may cost 10 Euros on Ebay. Total cost will be somewhat less than 200 Euros.Extensions
Printer extension, realtime clock, use of RF24 and a wire library are part of the BASIC interpreter. Read the wiki for more info.Final words
Why a BASIC based Arduino homecomputer? Because it was fun to build it. And an interpreter language is many advantages. One can test circuitry and IoT with it without the need to reflash the Arduino for every change. I will add more projects here with BASIC on the Arduino and other devices to showcase this. Read my project page to see what comes next.