Planning Out Your
Software for
Microcontrollers
By Matt Rusnak
Microcontrollers have certainly gained a lot of popularity in hobby robotics
and electronics during the past decade, partly due to their ability to change
the function of a circuit without any changes in hardware. This flexibility
makes it tempting to write software on the fly, but with a bit of planning,
programming can be much more systematic and yield better results.
This is not to say that I think tinkering is entirely bad. It can actually be one
of the more creative parts of a project and can lead to a lot of good ideas.
Taken too far though, tweaking the software continuously can cause you to
rewrite existing code over and over, and may keep your project from ever
being finished.
The Project
This article is mainly about a process
for developing software, so I have chosen
a fairly simple project to highlight its
implementation. My hope is that you will
take these ideas and use them in your next
robot build. It is a puzzle of lighted
pushbutton switches that appears in a
number of video games, usually as a door
lock. The idea is to start with all of the
lights turned on; pressing each switch
toggles its light and all of its neighbors.
To solve it, the player has to turn off all of
the lights.
Instead of just building the same exact
puzzle, I wanted this version to randomly
set up which nearby lights are affected by
each switch so that it plays differently each
time. It sounds simple enough, but
planning brings out a lot of details.
48 SERVO 06.2010