BASIC interpreter for the Arduino. Inspired by the Woz's Integer BASIC.

Similar projects worth following
I was thinking a few weeks ago, wouldn't it be cool if the Arduino had an operating system. Then I thought, way back when I just used basic and dos. So wouldn't it be cool to write a basic for the Arduino?

** this program is a work in progress **

but there are some fun things you can do.

to get it running first you need and arduino uno (or just a atmega328p) and a 23K256 SRAM. There is a schematic in the image gallery.

next download the tar file from the links and extract it using tar -xvf blinkyBasic.tar

or optionally grab the blinkyBasic.txt file and rename it blinkyBasic.asm and compile it with gavrasm.

then flash the arduino with avrdude. you need to id the usb serial connection in /dev/ then

$ avrdude -v -p atmega 328p -c arduino -P /dev/tty.yourserialid -D -U flash:w:blinkyBasic.hex:i

then open up a serial terminal app (I like Cool Term) and set it to 9600 baud. You may need to set preferences to handle backspace, tabs, bell char.

Here is a read me file that describes working commands and statements:


This program is supposed to work like Integer BASIC. Check out this link

  • Update: blinky_term.c and fixes

    Bob Burns03/14/2016 at 09:25 0 comments

    Hey all, thanks for the recent follows! I got a cool new job and so I have time again to spend on blinkyBasic.

    I wrote a serial terminal program for linux and for mac you can compile and use with blinkyBasic in the links area. Also, I fixed a couple of bugs with list and if then. The updated asm and hex files are in blinkyBasic.tar. You can compile with gavrasm or just flash the hex with avrdude.

    The next things on my list are tackling the save and load commands and getting input working.



  • ready for super con!

    Bob Burns11/13/2015 at 00:32 0 comments

    The PCB I designed with Fritzing came in the mail a couple days ago. I tried it out and to me surprise nothing started smoking.

    I was able to finish the list routine and a peek function which I'm happy about.

    Hopefully see you at the conference so I can show you my project.

  • dim x(100)

    Bob Burns11/07/2015 at 19:14 0 comments

    I've got dim working! It has taken a little longer due to the fact that last Sunday I got an email about one of my iOS apps not working, so I had to spend all my free time updating for iOS 9.1. Kinda sucked but if I was getting paid to be an iPhone dev, it would mean good job security. Anyway, so originally I wanted to be able to do two dimensional arrays (x(10,10)) but had to settle with one because the print function interprets a comma as a tab: print x(1),x(2). I don't think you could use two dim arrays in Integer basic anyway. One other caveat of my program for now is that you can't pass an expression to a dim index; just numbers or variables (x(i) = 100 not x(i-1) = 100)

    I updated the blinkyBasic.txt and blinkyBasic.tar if you want to have a go.

    This week I'm planning to tackle "list", and soldering up the pcb I ordered from Fritzing so I have something cool to show at SuperCon.

  • update

    Bob Burns10/25/2015 at 13:15 0 comments

    I updated the tar file and txt file so you can try it out if you want. I also updated the goto and gosub commands to handle expressions. This week I'm going to work on dim... dim x(100,100). I think I figured out a way to get up to 2K of int var space for 2 dimensional arrays. :]

  • SRAM working!

    Bob Burns10/23/2015 at 18:06 0 comments

    I swapped out the EEPROM for SRAM last night. It took me a while because I after hooking everything up I forgot the MISO line didn't need to go through the logic shifter because its already 3.3v coming back into the Arduino. The code was pretty easy. I'm going to probably use a different chip select when I write the save and load routines. (I'm planning on using EEPROM to save a file). Here's the SRAM wiring:

  • for next working!

    Bob Burns10/22/2015 at 01:24 0 comments

    Got the for next routines working today. Handling the negatives was a little tricky, but overall a lot easier then I thought.

    Right now it can only handle 4 nested loops. Also the variable after next is totally arbitrary. I'm not sure if you could step another loop within a loop. I'll have to check.

    I updated the .txt if you want to see the code. I'll update the download after I fix a couple of things.

    Next I'm gonna start working on swapping out the EEPROM for SRAM. :]

  • for next step

    Bob Burns10/18/2015 at 13:10 0 comments

    Today and probably the rest of the week I'm going to start working on the for next routine. I'm going to model it after Gates/Woz stack method of pushing the counter and start pointers on a stack, and popping them off every time a loop is done.

    My plan of attack is going to be:

    Get the next variable address and push it on the stack. (for a = 1 to 10 step 1. would be address of a)

    Get beginning value (1) and assign it to variable

    Get ending value (10) and push on to stack

    Get step value (1) and push. if no step assume 1?

    Get address of loop start and push.

    Update stack pointer.

    So every block is 8 bytes

    00 01 varL varH

    02 03 endL endH

    04 05 stepL stepH

    06 07 nxtL nxtH

    when a next token is encountered

    pop and store in registers: next address, step val, end val, var ptr.

    add step val to var and compare.

    if equal of higher branch out. update stack pointer

    if lower push everything back (or just update pointer) and branch to beginning.

    I need to handle negative case (for a= 10 to 0 step -1). Maybe a test for negative on step value switches the compare.

    Ok, time to go to my day job (I'm a cook for the UCSC dining halls ;) )

  • SRAM space pointers

    Bob Burns10/17/2015 at 22:45 0 comments

    One of the challenges of writing a BASIC for the Arduino is the amount of available SRAM space. The Atmega328p has only 0x8FF bytes which include the stack and the internal i/o registers. So what I did was use a 32K eeprom chip and locally store a table of pointers. So my SRAM space looks like this:

    0x0000 - 0x00FF register

    0x0100 - 0x0569 program pointer memory. 6 bytes per pointer: first 2 bytes are line number, 2nd 2 bytes are a pointer to the next line, and 3rd 2 bytes are a pointer to the EEPROM address. (0A 00 06 01 00 00 is line 10). I also wrote a neat algorithm so you can insert line numbers by pointing to the end of the ppm space. Equals 188 lines max.

    0x0570 - 0x062A int pointers. 4 bytes per poiner. first 2 bytes = 2 char name, 2nd 2 bytes = 16bit value. LSB first. 46 possible vars. But with the dim function I'm hoping to be able to use arrays.

    0x062B - 0x0655 string pointers. 4 bytes per pointer. like ints. maximum chars in eprom are 128 chars.

    0x0656 - 0x75F internal variables and pointers (265 bytes)

    0x0760 - 0x080C input buffer. for getline and other buffering

    0x080D - 0x0881 output buffer

    0x0882 - 0x08FF stack. 125 bytes of stack. tight squeeze.

View all 8 project logs

Enjoy this project?



haburton wrote 10/19/2015 at 02:53 point

If I'm not mistaken, the Arduino is based on the Atmel family of devices.  Aren't they sort of i8051-like devices?  If so, you might look at Intel's Tiny Basic or Bascom-51.  The Source code is out there on the web and may help speed up your development.  Good luck.;  I'd love to use it.

  Are you sure? yes | no

Bob Burns wrote 10/19/2015 at 11:36 point

Thanks! The Tiny Basic that I've come across seems just a little too tiny.  Some one has ported it to C and added some Arduino like commands.  I'll check out Bascom-51.  I have to admit, though I'm having way too much fun trying to write this thing myself. :]

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates