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... 
 HIGH 0:LOW 1
 GOTO lab5         ' done with case 1, exit
lab2: 
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
  END

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

if x == 1: 
    high(0)
    low(1)
elif x == 2:
    high(1)
    low(0)
else:
    low(1)
    low(0)

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…



Share: