DIY servo controlled pneumatic switches

Unless you have the materials and the skills, this is not for you. I will use this in a robot I’m working on, but Mindsensors sells pre-made versions of the same concept.

What this allows you to do is, using either a RC receiver or a NXT servo controller, make pneumatic robots!

These things are relatively easy to make. Materials:

  • A drilling machine
  • A drill of the same size as LEGO pins.
  • A small drill for the servo screws.
  • A jigsaw
  • A pen
  • Misc. LEGO parts.
  • A small servo with horn and screws.
  • Plywood.
  1. Saw a rectangle big enough for the switch and the servo.
  2. Draw a line around the servo, and a dot through the pinholes of the switch.
  3. Drill out the pinholes, and make an extra hole on the servo outline.
  4. Open the jigsaw, and put the blade through the hole on the line.
  5. Close the saw and saw out the servo hole.
  6. Drill small holes for the servo screws.
  7. Attach the servo and the switch to the wood with any LEGO at hand.
  8. Bend a piece of iron wire around the switch and the servo horn.

Generic programming tutorial

I have wanted to teach you some programming since I started this blog, but I refrained from doing so, because there are so many ways to program, and I want to use them all.

What I’m going to attempt, is not to teach you a programming language, but teach about programming itself. This may seem useless to you, but my experience is that when you understand programming, the language does not really mater, and you can program in anything that is not excessively weird.

For practical reasons, any code examples will be written in NBC, Python, NXT-G and Clojure.

A computer

To understand programming, you first need to understand what a computer is. For our purpose, it suffices to think of a computer as a processor, a block of storage, and a block of memory.

This is true for desktops, smartphones, the NXT, and anything else with these components. Of course there are some other components involved, which can be divided in inputs(keyboard, sensor) and outputs(screen, motor).

What a computer does, is read instructions from the storage, execute them on the processor, which modifies the memory and reads/writes to the in- and outputs.

To give you an idea, you could put instructions in the storage that tell the computer to store the number 2 in memory, copy it, and multiply the two numbers, saving the result in memory.

A more useful set of instructions could put the input from the keyboard to the screen, or read a sensor, do some math and control the motor.

A compiler

When I said instructions, I did not mean instructions in plain English. Processor instructions are not easy to read and write for humans, that is why we let computers translate them for us.

In its most basic form, a compiler is a set of instructions which converts words like “add” and “read” to stuff that a computer understands.

More advanced compilers also allow you to define new words, such as “turn left”, in terms of other words, such as “motor on” and “motor off”.

A language

A language is a set of instructions, as understood by a specific compiler. A language consists of a few things.

A syntax

This is like grammar for compilers. A few examples of adding a number:

  • Python: 1 + 1
  • Clojure: (+ 1 1)
  • NBC: add 1 1 result
Which are all the same thing, except that NBC is a statement instead of an expression, more about that later.


This is the hardest part of programming. But let me tell you, even good programmers don’t remember all APIs, you simply google them.

An API is the set of words at your disposal to express your problem. This API is different for every language.

In NBC there is a word called “OnFwd” which can be used with an output, like “OnFwd(OUT_A)”, but in Python, there is no such thing. Python doesn’t even know what a motor is, or what forward means.

However, people have already defined words to talk about the NXT in Python. To use words already defined elsewhere, we can say “from nxt.motor import Motor, PORT_A” in Python. Now we can say “Motor(my_nxt, PORT_A).run()”


Expression have a value. The value of (+ 1 1) is 2, so we can also say (* 2 (+ 1 1)), which has the value 4.

People commonly say expressions ‘return’ a value, which is what you do when you define an expression in Python:

def expressions():
    return 2


Unlike expressions, statements do not have a value. What would be the value of “while True:”(the start of a loop in Python)?

Note that not all languages have expressions and statements.

NBC has only statements, which is why you write “add 1 1 result”, so that the result of the addition gets saved in memory.

Clojure has only expressions. if something has no useful value, it returns nil.

Python is a mixed bag.


So far I have talked about that block of memory as an abstract thing where you save and retrieve values. In reality, it is very useful to label the box you put it in.

For example, in Python you can say

x = 1
y = x + 1

These are statements that store the value of the expression. ‘x’ now references the value of 1, which is 1. ‘y’ is now a reference to the value of adding the value of x(1) to the value of 1(1).


So far we used numbers as values, but what if you want to talk about a collection of things?

languages usually provide means of defining a collection of things, and for doing things to the elements or the whole collection, like sorting it, or getting/setting elements.

An array of 5 integers in NBC:

dseg segment
  int reference[5]
dseg ends


We talked earlier about the words that make up an API. In most cases, words are also just references to values.

These values are usually called functions, and consist of a collection of other functions.

Not all languages have functions as values. In NBC, functions are statements, which don’t have a value. Clojure, however…

(def x 2)
(def square (fn [n] (* n n)))
(square x)

Here, I defined ‘x’ a reference to the value 2, and ‘square’ a reference to a function that multiplies a number by itself. The, I called the value of ‘square’ with the value of ‘x’, resulting in the value 4.

Learning a programming language

I hope to have given you a good understanding of how a programming language works. To actually start using a language like NBC, you need to find out a few things:

  • How do I use words/call functions?
  • How do I define references to values in memory?
  • How do I define new words?
  • What existing words do I have at my disposal?

A good starting place is usually a beginners tutorial. Google for “<language> tutorial” and click the first result.

After a section or two, they usually start to talk about how to do things. You might continue, or stop here, and get your hands dirty. If you run into trouble, simply google for “<language> how to <problem>” or find the function reference by searching for “<language> function reference>”.

If you are really in deep trouble, Stack Overflow is a great website for asking questions.

I hope this is enough preparation for you to start learning, and for me to focus on explaining how to do things in any language needed, like plotting a picture with the NXT 😉

RCX Snow Plow

Over here in the Netherlands we usually have just a few days or weeks of snow per year. When the time comes, there are three things that absolutely have to happen.

  1. Go sledging
  2. Go ice skating
  3. Build a robot to drive in the snow

I wont bother you with the first two items, but I thought you might like number three.

I was surprised that I couldn’t find a single video of  a snow plow, plowing real snow. There are robots pushing LEGO around, and static models of a snow plow. This is what I made.

The robot is a regular half-track, but uses a triangular tread configuration to keep the motor out of the snow. It also has a rotation sensor on the unpowered front wheels, to detect the robot isn’t moving.

I’m not sure if you are interested in the software or building instructions, because it uses the RCX with parts from Ultimate Accessories and Ultimate Builders sets, as well as miscellaneous red parts. Are you?

NXT model of Twente One Solar Racer

I wrote earlier about the solar panels I bought from eBay, and how I connected them to the NXT. The next logical step was of course to build a robot, so why not start out with a solar racer?

I’m Dutch, so I started to look at the cars of the 2 Dutch competitors for the World Solar Challenge, the universities of Twente and Delft. Delft has won for several years in a row, but I still decided to go for the Twente car from 2007, called the Twente One.

I had several reasons for choosing the Twente one. Emotional ones, like a team member that gave a presentation about the car at my old school. Technical ones, like that the powered wheel is not also the steering one. But maybe the most interesting reason is that they have a tilting solar panel, for which they won the innovation price in 2007.

With my LEGO model of the Twente One, I tried to add all the same features as the original model, including:

  • Direct drive on the rear wheel, although the NXT motors are in fact geared down
  • Double wishbone suspension on the front wheels
  • Trailing beam suspension on the rear wheel
  • Tilting solar panels

Winter probably isn’t the best time to try to build a solar racer, but I still made a video of it driving around.

Besides of course the solar panels, this model also requires these motorcycle wheels and 4 springs of the strong variety. I had to buy these myself as well, totally worth it IMO.

I did not include building instructions for the solar panel, as they are easy to make and yours might be different. You could also just use a piece of cardboard instead(but that would be cheating). The panel connects to 3 pivot points at the top of the car.

Download building instructions