Below you can see the rest of the schematic integrated with
the voltage regulator from my last post. As I explained previously, the
PIC16F690 is the brains of my system. This PIC is a mid-range option for
hobbyists and has much more functionality than I made use of in this project. I
originally thought I would make better use of it when I was in the planning
stages but everyone who has been following me knows how things turned out. You
can see in the schematic I left 15 of the 20 pins open, which is a colossal
waste of space. A better controller to use would have been the ATTiny10 from
Atmel or a 6 pin micro from Microchip. Even the 16F84 that I had lying around
could have saved some space and provided the same functionality (flashing an
LED).
I was able to program the chip using an in-circuit
configuration with a PICKit 2 and could have included programming headers in
the design if I intended to reprogram these devices in the future. I have
included another schematic of the in-circuit setup I used for the programming.
You can substitute a small signal diode for the 47kohm resistor if that is
handier for you. From what I can gather this setup is pretty standard across
different families of microcontrollers and you can integrate this header into
your printed circuit board design for on-the-fly reprogramming. You just have
to make sure that the circuit isn’t operating while you are trying to program
it and that no power is supplied to the programming pins when you do want to
test the circuit. This is less of a problem if you don’t have anything else
connected to pin RA3 (configuration specific).
The software is brain dead simple and written in C using the
MPLABX IDE from Microchip (GUI pictured below). All it does is call a delay function by
passing an integer to represent the number of cycles through a 100ms countdown.
I varied the timing for this function with each different pumpkin to create
different patterns. The code I have uploaded to this post is based on a 20Hz
flasher to create a strobe effect. I have linked a zip file to this post with
all the necessary header files if you want to play around with lighting up some
LEDs yourself. You can download it here.
If you look at the datasheet for the 16F690, you will see
that PORTC corresponds to the RC0, RC1, RC2, and RC3 pins on the chip so you
must first configure PORTC as outputs before running the main piece of the code.
By setting these pins high in software, you place the chip’s supply voltage on
the pins in question (RC0-RC3) and start to source current to whatever loads
the pins are tied to. In my case, they are all tied to LEDs with current
limiting resistors. I have assumed Red LEDs in the schematic so different
resistor values are necessary for other colors/source voltage combinations. I
wanted to drive the LEDs at around 15mA so I used ohms law to determine the
correct resistor based on the turn on voltage of the LEDs. You can find online resistor calculators that will tell you what resistor to use based on your LED
color and the current you desire. Otherwise, look up the forward drive current calculation
for a diode.
That’s about all I have to say concerning this design. It is
easy to see why this project doesn’t amount to much more than a glorified LED
flasher. Some obvious improvements are software upgrades to lengthen battery
life, decreasing the size/pin count of my microcontroller, and adding external
triggering options to cue up the light sequences based on movement. My final
two posts dealing with this project will look at the circuit board design and the
highly anticipated bill-of-materials (BOM).