Candle Simulator using PIC12F675 microcontroller


The aim of this project is to create a credible simulation of the light of a candle. Candle light is usually warm and waves slowly with random oscillations caused by the air flowing in the surrounding environment. Using a random number generator to modulate a light emiter like a LED or a light bulb it is possible to create a very credible effect.

Candle Simulator


I tested both LEDs and small incandescent light bulbs and although LEDs require less current to produce the same amount of light, light bulbs tend to create a softer effect. In this circuit I’ll use LEDs but nothing stops you from using light bulbs.

The brightness of the LED is digitally controlled using Pulse Width Modulation [1], generated by the micro-controller. The amount of brightness and its oscillations are governed by a random number generator based on a Linear Feedback Shift Register [2].

PWM or Pulse-width modulation of a signal or power source involves the modulation of its duty cycle, to control the amount of power sent to a load. This is because the average power delivered is proportional to the modulation duty cycle. With a sufficiently high modulation rate, passive electronic filters can be used to smooth the pulse train and recover an average analog waveform [1].

A linear feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. Applications of LFSRs include generating pseudo-random numbers, pseudo-noise sequences, fast digital counters, and whitening sequences. Both hardware and software implementations of LFSRs are common [2].

Circuit Implementation

I’ll use both Microchip PICs 12F629 and 12F675 micro-controllers to develop the candle simulator. Each output pin of the micro-controler is limited to source or sink 25mA. This is enough to power a small 5mm LED but not a light bulb or even a more powerful 1W LED.

Schematic candle power

To power small light bulbs or more LEDs it is required to use a transistor like a bs170 n-channel mosfet, connected to the micro-controller. It will then provide the remaining power to the light bulbs or LEDs.


For more detail: Candle Simulator using PIC12F675 microcontroller

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us: