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


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.