used to detect the sounds and it is biased with a 15K
802 surface-mount resistor. When the microphone picks
up a sound, this causes a change of voltage; this is
connected to a PIC12F508 microprocessor. GP3 is used
as an input pin and is TTL (Transistor Transistor Logic).
This pin trips at approximately a positive .85 volts. This
means that a voltage pulse crossing the .85 volts’
threshold either way will cause the LEDs to flash.
At first, I had a difficult time getting the microphone
to trip the microprocessor. Most of the time when using
a microphone, you use a 1.0 µF or 10 µF capacitor. After
trying several different circuits using resistor and
capacitor networks, I found if I directly wired the mic into
the micro and biased it with a 15K resistor it worked
fined. The microprocessor is normally asleep, and a
change of voltage on GPIO 3 pin 4 causes it to wake up
and start its program. The output from the microphone to
the PIC is shown in Figure 1.
The eight colored LED anodes are connected to a
common trace. This trace is connected to a 100 ohm
resistor going to three volts positive. This resistor prevents
excessive current from being used by the LEDs. The LEDs
turn on in pairs. To view the program, go to this article’s
download file and find the drum file. There are only
about 100 actual lines of code, so it is a short program.
Although the lights look random, there are seven
different programs to make them flash in different ways.
The program starts at ORG 0 (the first line of code).
The commands after
the START label tell the
micro which pins are
IN pins and which pins
are OUT pins. The
allows GP3 to wake up
from sleep. Four is
loaded in the REPEAT.
Changing this number
will increase or
decrease the number
of times the LEDs blink
The 12F508 is unique when awakened; it jumps back
to location zero and starts the program over. Most chips
when awakened resume from where they were when
they went to sleep. The trick I used to call a different
light program when awakened is to use a flag register
and advance the flags each time a program is run. A
BTFSC (Bit Test File & Skip if Clear) is used to check the
flags. This is located in the label call Flag_routine. The
program continues until it finds a bit that is set, and
jumps to that program. Once it arrives at the light
program, clearing the bit BCF (Bit Clear File) will cause
the LEDs to turn on. A delay timer is used to set how
long the LEDs stay on. The repeat will determine the
number of times they flash with each beat.
You will note on the board drawing that traces 3 and
6 are tied together on the 508. This was done to free up
board space. One of the advantages in using
microprocessors is that you can short some pins together
and make one of the pins an input, and eliminate routing
of an extra trace.
One of my favorite chips is the 12F508 and it was
ideal for this project. The 12F508 is a great micro for
cutting your teeth on. It first came out as a 12C508;
however, you could only program it once. If you
programmed it wrong, you threw it away. For
experimentation, you had to buy a chip with a quartz
window and erase it if you were going to reprogram it.
These were not inexpensive (cost about $15 ea) and
August 2011 39