hn.today

Back to BASICs with a Pro Micro Microcontroller

kevinboone.me4 points1 comments
Screenshot of Back to BASICs with a Pro Micro Microcontroller

PMBASIC is a proof-of-concept, minimal BASIC environment implemented for the SparkFun Pro Micro microcontroller to recreate a 1970s-style interactive programming experience on an Arduino-like board. It targets low-cost, classroom-friendly physical computing by eliminating heavyweight IDEs and letting users type commands into a terminal over USB. The runtime fits within the Pro Micro’s constraints (32 KB flash, 2 KB RAM, 1 KB EEPROM) and exposes Arduino-style operations such as pinMode/digitalWrite/delay, analogRead, and direct memory-mapped I/O via POKE. Example programs include a simple LED blink and direct port manipulation; programs can be stored and retrieved from EEPROM and the system is likely portable to Leonardo-style boards with some adjustments.

Implementation mixes a line-oriented, ad-hoc parser with recursive-descent expression evaluation (inspired by uBASIC) to minimize resource usage: PRINT is handled sequentially while arithmetic expressions are parsed formally, and FOR/NEXT loops store program-text offsets on a stack for control flow. Editing is intentionally rudimentary - line-numbered input rather than full terminal control - to avoid terminal-capability complexity and to lean on desktop cut-and-paste. Error handling and parser entanglement inflate code size (error checks ~30% of code). Performance is modest (example: 10,000 null loops in ~17.6 s ≈ 500 loops/s), slower than equivalent C but sufficient for experimental and educational tasks.

Read on kevinboone.me1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Hardware

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.