OVER 5000 UNIQUE OPTICAL PRODUCTS
WITH 5,000,000 IN STOCK!
• Start Up
• Prototype • Research
• Single Unit Applications
• Educational Applications
• Initial Run Requirements
a division of Edmund Optics
A Catalog Devoted to Optics... New 68 page color catalog!
ANCHOR OPTICAL SURPLUS
Dept. B051-X960, 101 E. Gloucester Pike, Barrington, NJ 08007-1380
Tel: 1-856-573-6865 • Fax: 1-856-546-1965 • E-mail: nv@AnchorOptical.com
to each of the LEDs each tick. They
either stay on or off, or change state.
One revolution of the disk is equivalent to 128 ticks (a maximum of 16
on ticks and 16 off ticks per quarter
revolution becomes 128 ticks overall). Using a random method, an LED
is chosen to be on continuously, or
to flash. The rate of flashing is
controlled by two additional random
numbers, one for off-period ticks and
the second for on-period ticks. For
example, the numbers 7 and 12
would indicate 7 off ticks and 12 on
ticks. Arrays are used to keep track of
the tick counts, state, and pattern
type for each of the five LEDs.
While testing the software, I
flashed a new program into the PIC
and plugged the PIC into the development board. Then, by simply wiggling
the board back and forth, I was able
to see the LEDs flashing at different
rates, or staying on, with new patterns
emerging regularly. Listing 1 shows
the PIC-BASIC program that controls
When the software seemed to be working, I spent a
few hours building the prototype of the disk. In Figure 2
you can see the results of my attempt to duplicate the spinning disk. For balance, I placed the PIC microcontroller
and crystal in the middle of the axis of rotation.
Unfortunately, I did not notice the difference in LED colors
until after I had soldered them to the circuit, but as this was
a prototype, I didn’t beat myself up over it. Figure 3 shows
the schematic of the prototype.
All that remains is for me to mount the new
prototype disk in the old toy housing and see
how long it takes my daughter to figure out her
toy had undergone an operation. Even if I still
end up in the doghouse, at least now I know how
to program a PIC. NV
Circle #63 on the Reader Service Card.
About the Author
James Antonakos is a Professor in the Departments of Electrical
Engineering Technology and Computer Studies at Broome Community
College, with over 29 years of experience designing digital and analog
circuitry and developing software. He is also the author of numerous
textbooks on microprocessors, programming, and microcomputer
systems. You may reach him at email@example.com or visit
his website at www.sunybroome.edu/~antonakos_j
Figure 3. The PIC microcontroller offers a minimal part-count solution to
the prototype design. Five I/O pins are used to control the LEDs.
Figure 2. The original spinning disk rests side-by-side
with the new PIC16F628-based prototype.