It’s nearly Halloween and my family have been digging out Halloween decorations which is how a broken Tigger toy landed on my desk.

Opening the pumpkin and exposing the internal circuit/wires showed the source of the problem. Three of the power wires connected to the LEDs had snapped along with a battery ground wire on the original circuit board and both of the resistors each had a snapped leg.

The original control circuit is located inside the pumpkin, as shown in the photo below. The 5 LEDs fastened to the pumpkin eyes,nose and mouth are wired in parallel giving independent control over each LED. In addition the green stem on the top of the pumpkin is a push to close switch, I’m not sure the function it served with the original Tigger, possibly waking it up or changing the LED sequence?

Tigger with flashing pumpkin

Tigger with flashing pumpkin

Original control circuit

Original control circuit

Swapping out the resistors and reconnecting the power lines probably wouldn’t have taken long, but where’s the fun in that. Tigger was showing his age and in need of minor surgery.

The plan was to replace the existing circuit board with a new pic based controller, a motion detection circuit and speaker. However with Halloween just a few days away, reality took hold and I decided to swap out just the LED controller. Motion/speech can wait for another year.

Breadboard prototype

Breadboard prototype

A quick bit of breadboarding with the lowest pin count PIC I had available, PIC12F1822 resulted in a simple circuit with 5 LEDs independently controlled and a nMCLR pin repurposed as a switch to cycle through the LED sequences.

The new LED control circuit photo shows the PIC based LED controller soldered onto stripboard along with an ICSP header for future updates. Although a little longer than the SMT based original, it fit nicely inside the re-stuffed pumpkin.

New LED control circuit

New LED control circuit

Firmware

To save time I knocked up a quick bit of firmware in C rather than asm. The PIC is set to run at its lowest internal clock speed 32kHz and run one of 6 sequences. Pressing the green switch at the top of the pumpkin will interrupt the current sequence and cycle through the available ones.

To add a little variation to the 3 fixed sequences, I appropriated the PRNG used in Elite.

void cycleSeed(void)
{
   uint16_t sum = sgSeed.w0 + sgSeed.w1 + sgSeed.w2;
   sgSeed.w0 = sgSeed.w1;
   sgSeed.w1 = sgSeed.w2;
   sgSeed.w2 = sum;
}

the high bits of w2 are used whenever a random byte is required.

Tigger now supports 3 different fixed flashing sequences as well as 3 random sequences demonstrated in the video below.

  1. Random flashing of LEDs with a random delay
  2. All LEDs flash on and off
  3. Random flashing with a slower delay
  4. Cycling LEDs in order
  5. Random flashing with a faster delay
  6. Random cycling of eyes only

The three random sequences use cycleSeed to obtain a new pseudo-random byte which determines which of the 5 LEDs to light. In addition, the delay between moving to the next random set of LEDs is itself randomised. The slower and faster variants will generate delays in the range 1-500ms or 1-1000ms between each change.

The first sequence will also delay in the range 1-500ms between each change, however it will remain at a given delay speed for a short amount of time before randomly generating a new speed. Unlike the slow/fast variants which use a new random delay for each change.

Flashing an LED is perhaps one of the simplest circuits you can make and doing so in a sequence is not a lot more involved, but sometimes, simple is all that’s needed. That said, it’s tempting to make a new circuit for next Halloween with a larger pin count pic a speaker and motion detection. Then it’d be possible to write some more interesting firmware that plays games.