Color Globe using PIC16F688 Microcontroller




This was a fun little project I put together in a few
hours for a homemade-themed gift exchange this
Christmas.  I had on-hand a “Full Color LED” from
Radio Shack (part 276-0028) which caught my eye
on my last visit there.

The LED has a common anode and three
cathodes, one for each of the three primary colors:
red, blue and green.  By changing the duty cycle
(the fraction of time the pin is low) on each of the
three pins controlling the colors, I could create any
color.

Color Globe

The next step was the housing.  I found a good
candidate in a prize I had won for judging a technical
paper competition at Georgia Tech years ago.  It was
a sphere with a golf ball inside that you had to move
around until it balanced on a tee.  The sphere was a
good size and the polystyrene base made for an easy
mounting of the components.

My first thought for controlling the colors was a simple algorithm
that I think is called “the drunk’s walk” – for each step, choose
randomly which direction the step will be (one color a little
brighter, another a little dimmer).  The problem with this is that
you’re unlikely to get far; you’ll likely keep drifting around
wherever you start.  The chances of wandering all the way to a
vibrant color were small and I certainly didn’t want this thing just
showing different shades of off-white!

Instead I devised a configuration of 10 nodes:  three of them
pure colors, seven of them intermediates.  The globe would
start randomly on one of these nodes.  Every three seconds an
adjacent node would be randomly chosen and the color would
slowly shift to that one over the course of 20 steps.

Here is a graphical representation of the ten nodes showing
(roughly) their colors.  The numbers show proportions of red,
blue and green respectively.

The result is a random walk that gets to the more vibrant
colors reasonably often.  To be really nit-picky, I don’t use all
of the colors that could be generated, only those along the
defined paths.

The circuit is quite simple – a battery, a 5V regulator, a PIC
16F688 microcontroller, and three 470-Ohm resistors from
the LED to the control pins.  I later replaced the battery with a
plug consisting of a “wall wart” transformer and a 9V clip.

 

For more detail: Color Globe using PIC16F688 Microcontroller




Leave a Comment

*
= 5 + 8

Read previous post:
Soundtrack using PIC16F688 Microcontroller

This project uses a microcontroller to drive a speaker and play one of two songs: Yakety Sax (the chase song...

Close
Scroll to top