jon black

"I am in a charming state of confusion"

What are the best headphones for programming?

When we sit down to write code we all desire coding nirvana, where the world around us melts away and we achieve an inner peace, the code appearing to write itself.

One of the obstacles to reaching such a relaxed and focused mental state is distraction from noise. Like a toddler incessantly poking your arm, it robs you of your attention.

This is why headphones are essential gear for programmers.

They enable us to shut out the world and concentrate on the code, making coding nirvana easier to attain. But with so many different types of headphones on the market, how do we know which ones to choose? Are some better than others for programmers?

Types of headphones

There are four different types of headphones, and knowing how these types affect sound isolation is essential for understanding which are more suitable for programmers.

Earbuds sit loosely in the outer-ear facing,


How to program the Arduino using vim

The Arduino IDE leaves a lot to be desired. Granted, it's easy for beginners to build and upload sketches, but as a text-editor it makes you want to smash your keyboard against your monitor. Repeatedly.

Files open in new windows instead of a tab, and there are no advanced features like auto-complete; did I mention it looks like a relic from the Windows 95 era?

This article describes how you can free yourself from the shackles of the Arduino IDE and program your Arduino using vim.

arduino-makefile

arduino-makefile by Sudar Muthu is a great project that allows you compile, upload, and monitor the serial port using a simple makefile.

How simple you ask? 4 lines! Seriously. And one of those is blank!

Let's work through an example together, from scratch. Let's create a makefile for the legendary Blink sketch.

1. Install the Arduino IDE

The Arduino IDE is still required


Arduino multitasking using finite state machines

Beginner Arduino programs tend to focus on a single goal, such as blinking an LED or spinning a servo, where the timing is controlled using delay; the famous blink sketch is a prime example:

void setup() {  
  pinMode(13, OUTPUT);
}

void loop() {  
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

This works well for single tasks like blinking an LED; however, delay prevents multiple tasks from running concurrently. We can easily add another LED to the blink sketch and have it blink in time with the existing LED...

void setup() {  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop() {  
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  delay(1000);
}

...but if we want the LED's to blink at different rates, where for example the first LED stays on for three seconds and the second stays on for two seconds, we'll find that delay pauses


Perfection and procrastination

The amount of pressure that software engineers put on themselves is monstrous. Our view of world as a finite, discernible system causes us to aim for nothing less than perfection. With such high expectations, it's no wonder that we procrastinate, struggling to find a place to start. Thankfully, according to The Book of Life, this is a very honourable problem:

People who don’t know where to start are often perfectionists. It’s an honourable problem: you’re doing nothing not because you’re lazy but because you’re very ambitious. Perfectionism is one of the causes of procrastination – because it makes us so worried about getting things wrong.

Yet in spite of this honour, and when faced with the daunting task of creating perfection, we lay down our arms and reach for the white flag. We then compose a list of our inadequacies and view our perceived failure, and


Pick a language, any language

When you get started with programming one of the first obstacles is picking a language. A mistake beginners often make is asking experienced developers where they should start:

Search which language

The truth is it doesn't matter.

The first programming language I was taught was Pascal. This was long after my childhood experiments with ST BASIC. The year was 1998 and I was 17 years old. In case you're not familiar with pascal, here's its "hello, world":

program HelloWorld;  
begin  
  WriteLn('Hello World')
end.  

I've not used this language since. If you were to ask me to write a program using this language now, I'd need a book. In fact, I had to search for the example above.

That doesn't mean it was a waste of time. Through Pascal I learned basic programming concepts such as variable assignment, loops and if statements; it even introduced me to object oriented programming.

I had a