The end of the program we enter an
infinite loop that flickers the day’s candles
— and that’s all there is to it. This is a very
simple program, and when combined
with the beauty of the electronic wicks, it
results in a beautiful display.
PUTTING IT TOGETHER
■ FIGURE 4. Menorah ontrol — top. ■ FIGURE 5. Menorah control — bottom.
For pure numeric use, this isn’t necessary, but if we’re
dealing with parallel outputs like the candles in this project,
it’s best to call RANDOM at least three times. I’ve experimented with other values, and three seems to work best.
Now that we’ve got an apparently random set of bits
we can do a bitwise AND with the mask to disable those
candles that are not supposed to be lit at this moment. A
small, somewhat randomized delay is derived from the
random number and this value is added to an accumulator.
Once we have “lit” candles for about a second, we can
return to the caller.
From time to time, I get questions on creating a random
value between X and Y. First, we need to call RANDOM, and
doing it frequently is best. The general formula, then, works
out like this: value = random_number // (X + Y + 1) + X.
This works because the modulus operator returns a
value between zero and the divisor minus one — this is why
we add one to the span for the formula.
Back in the main section, we can increment the day
pointer and write it back to the EEPROM for the next cycle.
As you can see, we use our friend the modulus operator to
wrap the day value from eight back to one, making the
Menorah ready for next year.
dyNum = dyNum // 8 + 1
WRITE Day, dyNum
■ FIGURE 6. Wick PCB Panel.
Since the Menorah control section is
a one-off project, I decided to make
things easy by assembling the ULN2003
output drivers and terminal blocks on the Parallax BASIC
Stamp Super Carrier. This board will hold any 24-pin BASIC
Stamp module, the Javelin Stamp, and even the BS1-IC if
you like (which won’t work for this project because we
need nine outputs). The board has a 2.1 mm barrel
connector for power, a beefy five-volt regulator, and a
standard serial connection for programming the BS2 or
Javelin. For $20 (which does not include a BASIC Stamp),
this seems like a really good deal, especially when one
considers the time and energy to lay out a custom PCB, or
hand wire the whole works.
The user section of the Super Carrier has convenient
dog-bone pads that make adding the two ULN2003s a
breeze. I got a bit lucky in that I could just fit five, two-position terminal blocks (found them at RadioShack) into
the board for the common plus nine wick control outputs.
Everything is connected with point-to-point wiring using
#26 gauge solid wire. I kept all connections on top, save
one, as the easiest place to grab the Vin voltage was from
the AppMod header. I removed the solder from this pin and
made the V+ connection there. Figures 4 and 5 show the
top and bottom of the completed control board.
I just said that I wouldn’t lay out a board for the control
section, but for the wicks I sing a completely different tune.
I have hand-wired wicks in the past and believe me, it is not
any fun at all. If you’re going to do just one small project,
that would be fine, but if you are going to build more than
one project with the faux candles, you can either get them
pre-built or build your own wick PCB.
I’ve saved you the trouble of laying out the wick PCB.
In the download file, you’ll find a panelized PCB in
ExpressPCB ( www.expresspcb.com) format. ExpressPCB
offers great service and very good prices, and I use them
frequently when prototyping devices for my clients. The
wick PCB is small, and as you can see in Figure 6, 21 wick
boards will fit onto a “mini board” PCB. What this means
is that for a standard order of three mini boards, you’ll end
up with 63 wicks — that’s a lot of candles, and a possible
opportunity to split the board cost among friends!
The wicks are installed in short, pillar-style candles
because these are the easiest to work with. After burning
them for an hour or so to create a bit of a well, a 1/2” hole
is drilled through the centerline to make room for the
electronic wick. Use a wood boring bit and do go slowly;
I learned the hard way that getting too aggressive can
cause the candle to split. After coring the candles, I did a