By Any Other Name

When I got started in computers, we were sort of like mysterious high priests and I think I liked it better. Today, computer professionals either are under intense scrutiny from suits, or lumped in with someone’s nine year old who is “a regular computer whiz.”

Even our little embedded niche has been invaded over the years. High school kids make robots, and “makers” play with Basic Stamps and Arduinos. It is surreal to get a question about reading a temperature sensor via SPI while in line at the grocery store.

Don’t get me wrong, I have worked with many student groups and I like the Basic Stamp for simple one-off projects. (I’ve even written a few books about the Basic Stamp.) The Arduino, on the other hand, really annoys me. If you haven’t run into the Arduino, it is a simple development board aimed at hobbyists. The circuit is simple but the real thing of interest is the built-in bootloader that communicates with the development environment via a serial port. Because of the bootloader, you don’t need a programmer, just some software on your PC.

The idea is fine. I like the Atmel CPUs that power the Arduino. I have designed several systems with bootloaders myself. But what annoys me about the Arduino is that it introduces beginners to unnecessarily wrong terminology. When someone stops you at a coffee shop and asks you an Arduino-related question, you’ll be glad for this Arduino to normal cheat sheet:

  • Wiring – the GNU C compiler with a simple IDE that knows how to talk to the Arduino bootloader
  • Sketch – A C program for the Arduino
  • Shield – a daughterboard that fits many Arduino boards to add some extra hardware

Don’t be fooled. Sketch sounds like something graphical, but it is just a C source file. Well, sort of. The Arduino library has code that must look something like this:


int main(void)
{
	init();

	setup();
    
	for (;;)
		loop();
	  
	return 0;
}

Not really rocket science. Any code you want to run once, you put in the setup function (init is used by the library). Any code you want to repeat over and over goes in loop. The library also has a nice set of calls to control the onboard hardware (what we would call a board support package). A typical LED blinker looks something like this:


int led= 13;                 // LED on many Arduino boards

void setup()                  // do this once
{
  pinMode(led, OUTPUT);      // digital port to an output
}

void loop()
{
  digitalWrite(led, HIGH);      // LED on
  delay(200);                // wait for 200ms
  digitalWrite(led, LOW);      // LED off
  delay(200);                // 200 more ms
}

So the verdict? The Arduino isn’t a bad choice for its intended market segment. I’m not entirely sure how it attained near cult status. I just wish it didn’t teach bad habits.

Leave a Reply

Your email address will not be published. Required fields are marked *

*