LightLogo: A Logo Programming Microworld on an Arduino

Brian Silverman is releasing LightLogo. Loaded onto an Arduino, it is a microworld, as Brian explained to me at CMK15, for us to "get back to text programming." Since Brian explained the intent better than I can, let me share his summary.
LightLogo can make interesting patterns emerge with 10 lines of code. 
Sequence, repetition, variables, naming: 80% of what coding is about; add if and you are almost there.
[People teaching coding are] confusing between [the] act of coding and thinking algorithmically.
[Thinking algorithmically is] learning how to express a sequence of things that express itself over time.
LightLogo can be downloaded from the link above. Make sure your computer successfully talks to the Arduino by installing the appropriate FTDI drivers. Brian wrote documentation on how to flash the Arduino to run LightLogo, so use that as your guide to getting that up and running.

Next, build your light ring. I used three short pieces of 22 gauge solid core wire from which I stripped about a half inch of insulation from each end.

I bent the wire into small loops in the PWR, GND, and IN connectors on a 24 LED NeoPixel ring. Make sure the wire rings are snuggly attached to the NeoPixel ring. Optionally, you can solder the connections if you like.

The PWR wire connects to the PWR on the Arduino, the GND wire to GND, and the IN to port 2 on the digital inputs on the Arduino.

The wire can be bent to hold the light ring in a visible manner.

Connected to the computer, you can interact directly with the light ring in the LightLogo program. Typing the following commands, pressing "Enter" after each line
fd 6
setc blue
fd 6  
will illuminate the first 6 LEDs in red, then the next 6 in blue. The Turtle is a pixel, or many pixels at once, in this microworld. 

You write your LightLogo procedures in a word processor and save them as text files with a .txt extension. Remember Brian's advice to write small procedures that are perhaps 10 lines long at the most when building your procedures. Call the subprocedures from a master procedure, typically called startup in the samples included with LightLogo.

Let me walk you through a project I programmed while on vacation and chomping at the bit for the software to be released to a larger audience. I will walk you through the small subprocedures then show you how I called them all from the master startup procedure.

Here, I model a rainstorm in LightLogo. My rain might look different than your concept of rain, but it is pretty cool how this came together.

LightLogo purposefully has a very limited vocabulary: you are exploring how patterns emerge in lights controlled by short procedures, after all. Most commands are familiar to anyone who uses Logo, but there are a couple of exceptions I use in these procedures.
pe -- pen erase. The turtle turns lights off as it moves. 
clean -- turns off all the lights, sets the position to 0, sets the heading to 1 (clockwise), sets the color to 0 and puts the pen down. 
stamp -- sets the color of the light under the turtle to the current pen color. 
loop -- repeats a command indefinitely.
setc -- sets the pen color. The colors are numbered between 0 and 100.
setpos -- sets the turtle's position. 0 is the top. 
reset -- same as 'clean' and also shows the turtle and resets the brightness to the default value.  
setbrightness -- sets the brightness of the current pen color. The default is 20. 99 is the maximum.
 First, a procedure to drip:
to drip 
Next, a procedure to bigdrop
to bigdrop 
all blue
wait 50
The last subprocedure is to smalldrop
to smalldrop
setc blue 
setpos random 0 24 

The master procedure brings all the subprocedures together. 
To startup
[setc white 
setpos 0
repeat 24 [drip wait 25] 
setpos 0
setbrightness 20
setbrightness 20
repeat random 25 125
wait 100]] 
The Vine at the top of the page shows the procedure in action! Here is a longer version of just the light ring running the procedure on a loop.

I highly recommend LightLogo as a great introductory hardware project. You get to load alternative software onto an Arduino. You get to build your own light ring. There is nothing stopping you from building a container to hold the Arduino and the light ring, to take the project further. 

I also heartily recommend LightLogo as a great software project. The limited vocabulary is clear and concise. The encouragement to explore the power of text programming, nearly lost outside of more muddy or difficult to master text programming languages, is made possible by this microworld. People can directly interact with the LEDs and patterns created through their experimentation, then progress to writing subprocedures and procedures in a text document that can be downloaded to the Arduino. It is an amazing microworld. Recall Dr. Papert's description of a microworld as a place where a child might learn "undisturbed by extraneous questions."

Take the time to explore this wonderful hardware and software combination when you return to your students this fall: both you and they will enjoy creating amazing patterns and designs from light!


Bill Van Loo said…
This looks great, Josh, and I am definitely very interested in using this for my upcoming 7th grade programming course.

Can you provide any more details? Does it only run on the 24-light NeoPixel ring, or will it also run on other hardware (like a 16-pixel ring, or a NeoPixel strip)? Does it run on the Gemma, or only full Arduino boards? For example, I have a Gemma with a 16-pixel ring soldered to it (see my demo here: and wondered about running that.

Thanks for sharing this!!
Josh Burker said…
Thanks Bill!

Right now the hardware requirements are an Arduino Uno Rev 3 or the SparkFun Redboard. The Sparkfun 24-light NeoPixel ring is also the only supported light configuration.

Have fun!