Instructables
An led not only lights when power is applied, but also generates a tiny voltage when light is applied. A PICAXE microcontroller can be used to monitor this voltage. I will show you how to make a electronic candle that will flicker an led when it gets dark.


Step 1: Assemble the "candle"

Picture of Assemble the
The candle part of the circuit is a piece of perf board with a green led, 220 ohm resistor, diode,capacitor and a M08 picaxe. I used molex connectors to make the perf board detachable from "power stalk" made from twisted 18 gauge enameled wire. You can use insulated solid wire such as building wire for the stalk. You can also use a yellow or red led. White and blue leds don't work well as light sensors. The diode protects from reverse polarity and allows using alkaline cells by dropping the voltage to the picaxe a bit. Nicad cells work well with picaxes.

Step 3: Program your Picaxe

Picture of Program your Picaxe
As you picaxers know, you will need to program the picaxe. Below is the program:

'picaxe program to flicker led like a candle when dark

start:
input 1 'make pin 1 an input before reading with ADC
pause 200
w0=0

main:
low 1 'discharge led before reading
input 1
random w0 'get numbers to set flicker rate
readadc 1, b2
if b2 < 10 then dark
goto main

dark:
'led will flicker depending on value of b0 and b1
high 1
pause b0
low 1
pause b1
goto main

Cut and paste the program into your latest copy of the free picaxe programmer software. For newbies with the picaxe go to this site for info about the picaxe.
http://www.rev-ed.co.uk/picaxe/

For a simple programmer use this circuit to build a programmer. Program the picaxe and remove to place the picaxe in the candle.
 
Remove these adsRemove these ads by Signing Up
YAY PICAXE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! go picaxe!!!go picaxe!!!go picaxe!!!go picaxe!!!go picaxe!!!go picaxe!!! nice idea, i like the way the led is the input AND output!!!! i like picaxe!!!
NetReaper5 years ago
This looks really cool but I cant help but think a photoresister would be easier
botronics (author)  NetReaper5 years ago
Oh sure, you could use a photo resistor, a resistor and a transistor to eliminate the pic too. This is just a way to demonstrate the dual function of the led with a programmable device such as a pic. By changing the program, you can make it blink, flicker or come on when light is present. Easier is welcomed, but not always better.
Da_Fudge6 years ago
go picaxe! go picaxe! woo hoo! great 'ible
WattSekunde6 years ago
Great idea to use the LED as a sensor too.
Very well done.
Wow!
This Instructable is:
  • Very nicely done.
  • Very neatly done.
  • Great job!
  • Great pictures.
  • Great detail.
  • Great everything.
You did everything just fantastic, and I hope to see more, this Instructable is really and I mean really good.

Great job.
+1 rating.
botronics (author)  GorillazMiko6 years ago
Well thanks!, it good to share.
Buzz_Kill6 years ago
I love it. Q: How long will this run on a set of batteries? And how dark does it need to be before it is triggered?
botronics (author)  Buzz_Kill6 years ago
The picaxe is low current, It should run for days on a set of batteries. You can adjust the theshold of turning on in the software. Mine goes out in a partly lit room. Does not need complete darkness. Somewhere I have a light meter, thats a good thing to measure and graph.