E-Scribe : a programmer’s blog

About Me







Pile o'Tags

Stuff I Use


Spam Report


Software, meet hardware

My friend Matt recently got a microcontroller kit as a present. It's pretty geek-tastic -- you wire up circuits on a little breadboard, write code on your PC, download the compiled code to the microcontroller, and run. At which point, depending on your skill and ambition, your LED blinks, your piezo buzzes, or your robot limbs and sensors do their thing. And your cat runs into the other room.

All very cool, but the language -- a BASIC dialect called PBASIC -- overwhelmed my delicate sensibilities. For example, take this bit of code (found on the web)...

x VAR Byte 
IF x=1 THEN lab1   ' test for case 1
 GOTO lab2         ' case 1 false, try case 2
lab1:              ' case 1 true, do this... 
 GOTO lab5         ' done with case 1, exit
IF x=2 THEN lab3   ' test for case 2 
  GOTO lab4        ' case 2 false, try next case
lab3:              ' case 2 true, do this...
  HIGH 1: LOW 0
  GOTO lab5        ' done with case 2, exit
lab4:              ' this is case else
  LOW 1: LOW 0     ' do this...
lab5:              ' point of exit

...how could you not want to rewrite it into something like this?

if x == 1: 
elif x == 2:

Maybe the fact that I was thinking about these things means I'm truly a software guy, and not a hardware guy. I'm sure that at my level (zero) it doesn't really matter what the high-level language is. But in order to really scare the cat, we're going to need something more powerful...

Monday, January 8th, 2007
