Arduino BASIC?

I was thinking earlier today about making a small BASIC interpreter for the Arduino. There's plenty of ROM space on a 328 to make something comparable to the old Microsoft BASIC that ran on the Altairs.

RAM may be more of an issue. Traditionally, the old micros would keep the program in a slightly compressed form in RAM and run from there. I'd could see an Arduino BASIC starting with that approach, but it would be really interesting to try to actually store the program in the ATMega's Flash memory. Alas, you can only write to Flash a page at a time, so maybe a byte-writable SPI Flash would be a better medium to modify. You could write line-numbered statements out to Flash in a log-fashion, with an in-RAM line number table pointing to the data. At startup, you'd just read lines, altering the table until you get to the end of the log. The "NEW" command would just reset the log and erase the flash, and you could garbage collect by LISTing the program to the terminal, doing a NEW, then resending the program.

The nice thing about a BASIC on the Arduino would be the immediate feedback. It could have extended commands for the various reads and writes.

Has anyone tried anything like this?

Don't forget the EEPROM. 512 bytes (1024 in the newer arduninos) is not too bad, especially if you pre-tokenize things.

Someone has written an interpreter that would process basic-like statements from the serial port and such, but they called it something weird and I can't find it :frowning:

There have been a couple generic AVR projects along those lines that could be ported to Arduino:

http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=688&item_type=project

You might find this interesting - a Basic compiler for Arduino.

http://www.rhombus-tek.com/BC4Arduino.html

Andrew

That's OK, but I think the real advantage of BASIC on the device is that you can run commands directly from the terminal. You can play around with a few things without even going through the process of making a sketch and downloading. Given that constraint, maybe only storing statements in EEPROM or RAM is OK... once you've scratched your itch, then you can do a proper sketch.

Someone has written an interpreter...

There's this one: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236358622/4 that understands these commands: "pinMode", "digiWrite", "digiRead", "analWrite", "analRead", "servoEnable", "servoAttach", "servoPos", "servoStat".

Then there's "Breakfast" and it's associated EggShell on the PC: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225355039 and http://inhocsignovinces.net/ (this may have been the one you meant westfw).

There's also "Bitlash": http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225455201

Hopefully these will give you some ideas.

Andrew

Thanks Andrew - "bitlash" is the one I was thinking of.

bitlash looks pretty awesome and scratches the itch. I've got to download it and try it out on a 328, possibly integrating it with the TLC5490 library to control my RGB LED shield.

FWIW, I just posted a Bitlash update to http://bitlash.net; you can read about it here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1243990789/0

Cheers,

-br