For those who don’t know what BASIC is, it is a general purpose programming language, and the acronym stands for Beginner’s All-purpose Symbolic Instruction Code. It was created in 1964 and became widespread on microcomputers in the mid-1970s and 1980s. A fun fact–Microsoft’s first product was a BASIC version for the iconic Altair (the microcomputer that started the PC revolution), called Altair BASIC, weighing in at 4K.
Here’s some good news, a BASIC interpreter has been ported to Arduino thanks to the work of Gordon Brandly, Mike Field and Scott Lawrence! Now you can easily get a grasp on how it felt to program a simple script back in the 80s, while you control stuff with Arduino. Follow these steps to load BASIC onto your Arduino:
- Download Arduino 1.0.6 (doesn’t work with 1.6.X).
- Download the sketch TinyBasicPlus.ino from the github repository.
- Upload the sketch to your Arduino (tested in 8-bit family).
- Open the Serial Monitor, select 9600 baud and carriage return.
Look at the set of commands in the README. BASIC is an interpreted language, meaning that it will read and execute each line of code you write in the console, without compiling (the only compiling process is when you upload the sketch to Arduino). You can run lines of commands as you type them in, or you can write a script and execute it all at once. For example, you can turn the on-board LED writing this command:
>DWRITE 13, HIGH
Or you can print something to the console:
>PRINT 2+2 4
You can store lines of code on RAM and execute them later by entering a number in the line code:
>10 print 1 >20 print 2 >30 print 3 >run 1 2 3
There’s the list command, very useful to show your current script:
>list 10 PRINT 1 20 PRINT 2 30 PRINT 3
Here’s a short script that will make your Arduino LED (pin 13) blink 10 times:
>10 FOR A=0 TO 9 >20 DWRITE 13, HIGH >30 DELAY 250 >40 DWRITE 13, LOW >50 DELAY 250 >60 NEXT A
And there’s much more. If you feel inspired, you can build a standalone computer like this one I built: https://www.youtube.com/watch?v=vciQG9IFYi4 . Feel free to ask any questions, and enjoy!