I recently painted up a wizard I had bought from a wargaming supplier; to make him more in keeping with the Discworld theme of my model railway layout, I gave him a hat, removed his sword, and added some glitter to both robe and hat.
I then wondered if I could replace the knob on the end of his staff with a flashing LED. I found a suitable transparent bead in my daughter's craft supplies - the hole through the middle was sufficient to take a pre-wired SMD white LED, so I removed (white metal) knob and drilled a hole down the staff (it comes out just below his hand).
The flasher could not be simpler - most of the components are power supply - the 08M2+ does all the work.
There is a video here Youtube video of wizards staff
The code is simple: The LED brightness is ramped up quickly then dies down more slowly. The flashes occur at pseudo-random intervals of up to 65 seconds.
; program to make the knob on the end of the wizards staff
; rev 2 shorten turn-on time
; to use the 08M2 chip
symbol dutycycle = b0
symbol offsetcounter = b1 ;offset counter for getting array contents via lookup
symbol CntDly = w4 ; a word variable for random delay
symbol ModulatorOutput = C.2
pwmout pwmdiv64, ModulatorOutput, 63, 0 ; set up PWM channel and set it off
dutycycle = 0 ; initialise duty cycle variable
CntDly = 1234 ;initialise random variable
main: ;main loop
pause CntDly ;pause for up to 65 sec
;subroutine for flashing the led
; the array in the lookup line is used to change the brightness of the LED
; it goes from off to half brightness, then full (255) then decays away to
; off after which the subroutine returns
for offsetcounter = 0 to 11
lookup offsetCounter, (127,255,170,113,75,50,33,22,14,10,6,0), dutycycle
pwmduty ModulatorOutput, dutyCycle
pause 40 ; pause for 40 mS