American Constitution Candle

Yet another (decidedly tongue-in-cheek) LED candle project. This one takes textual input to produce a semi-random flicker effect.

Similar projects worth following
A few years back, Pete Mills published yet another excellent little project on his web site where he actually sampled a real candle (Mmmm, tasty!), saved the data on board an ATTINY85 and then "replayed" it through an LED. Very neat!
Martin Harizanov took Pete's project and tweaked it a little to add some on/off functionality and republished his version of the code.

I thought it might be interesting to take some -other- sampled data, stuff it into a micro and see what it looked like when squirted out through an LED.

The sampled data is text. The micro is a PIC12F683 and the programming language is JALv2.

Apologies to Pete and Martin for stealing their code and butchering it so cruelly.

I'm not Merkin', but I thought it might be fun to start off with some fairly well-known text, so the first example consists of "We the People...". Having said that, you can replace the text in the source with whatever tickles your fancy. The second example is the sillylollyquay from Hamlet ("To be, or not to be..."). It might also be interesting to take some double-byte text (Genjinomonogatari anyone?) and see how that fries up.

When you add your own text to the source, you should realize that the longer it is, the more "random" it will appear. However, while the PIC12F683 has quite a large slice of memory for such a small chip, it is still fairly limited, so your text will be silently truncated by the compiler to 1kB. You can verify this by running the .cod output file from the compiler through something like:-

strings Hamlet_candle.cod | sed -e 's/4//g' | egrep "To be" | wc
The "strings" command pull ASCII text out of the file. The "sed" filters out the "4", inter-character delimiters and the the "egrep" just pulls out the actual lump of text we're interested in (as opposed to the scads of assembler labels) and hands it off to "wc" to provide a count of lines, words and characters (note that the newline character at the end of the text takes us one character over the real 1024 count).

You obviously need to tailor that command a little to whatever text you're using.

The actual JAL source is fairly short. The "pragma" defines at the beginning of the program tell the compiler that we're using a clock frequency of 8MHz, that we're using the internal clock (no external crystal or resonator), no external reset and that almost every other feature (watchdog-reset, brownout, etc) is disabled.

The following section includes a few of the standard JALLIB libraries to provide support for delays, random-numbers and PWM. Those includes are followed by the definitions of the output pins.

Next come the variables and constants ...with the text as one long, unbroken line as a single constant.

  • 1 × PIC12F683 8-pin Microcontroller from Microchip
  • 1 × LED(s) Amber, white or red LEDs
  • 1 × Resistor(s) Select for supply voltage and LED type
  • 1 × Stripboard Sunhayato ICB-86 (Each board produces two circuits)

  • 2
    Step 2

    This project is fairly simple and is laid out on one half of a Sunhayato ICB-86 stripboard which has been cut down the middle on column 13 (check your local Amazon for ASIN number B004XHPMB8; you may be able to get it locally - about $1 U.S. each). Apart from the programming of the chip itself, this is a suitable project for beginners and chillen who are familiar with the use of a soldering iron. JALv2 is a fairly simple programming language and is an easy stepping-stone on to C.

    The board layout diagram shows a generic layout, with up to 5 LEDs on the board. Note that the source files have varying numbers of LEDs. The Hamlet candle file implicitly defines (via the PWM library include) the the CCP1 pin as the output, which is physical pin number 5 on the 12F683. If you're only going to populate one LED on the board, then it should be the one attached to pin-5 (the LED marked as "D2" on the layout).

    The AConst candle file defines more output LEDs, but as it stands only uses the same CCP1 pin for output and the GP4 pin as a debug indicator to show when a "wind gust" is active (the "Blazing Saddles" option). Feel free to play around with the number of active LEDs (and their colours) to get the best effect, The 12F683 is quite a robust little chip and fairly difficult to fry (what? bad-pun? me?), so this really is a nice little, low-cost circuit for fooling around with.

View all instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates