This was a project that I built a few years ago after I saw real fireflies for the first time up north. Fireflies are usually found in damp forested areas. It is rare to find real fireflies in the city , so I built this project to have simulated LED fireflies in my front garden.
It worked great and I got many people coming up to me asking where I got them. The only issue I experienced was after a few years of operation the connections to the LEDS corroded and I had to fix them up. If you plan to use this circuit outside in your garden, make sure to weatherproof it very well.
The heart of the circuit is a 16F630 microcontroller that runs the program to fade each LED on and off like a real firefly. The microcontroller blinks each LED on quickly then it slowly fades out like a real firefly. The microcontoller picks randomly one or two LEDs to blink on each cycle. The microcontroller then waits a random number of seconds before blinking on a new LED.
In the application notes below you can see how to configure the microcontroller by connecting pins to ground to select how fast or slow between firefly firings. The microcontroller can be set to as fast as 1 second between firings to as long as 30 seconds between firefly firings.
The microcontroller comes pre-programmed so you don't need any special programmer or progamming experience to build this circuit. Basic soldering skills and components are all that is needed.
For the best looking effect, use small 3mm LEDS that are yellow-green in color. Look for LEDS that are around 570nm in wavelength.
Pin Name | Description |
---|---|
VDD | +3V to +5V DC supply |
MODESEL1 | Mode selection pin for configuring operation |
MODESEL0 | Mode selection pin for configuring operation |
RESETb | Active low reset |
FIREFLY0 to FIREFLY7 | Firefly outputs for LEDS |
NC | No Connection. Leave unconnected |
VSS | Ground |
The microcontroller runs off 3V to 5V DC only. Using other voltages will destroy the microcontroller. For use with LEDS only. Make sure to provide the proper series resistors for the LEDS to limit the current to less than 20mA each.
You can run this microcontroller circuit off of 2 AA type batteries in series to get 3V operation. However, the preferred method is to run on 5V operation using a voltage regulator , for example the LM7805. Connect the VDD pin to 3-5V DC and the VSS pin to ground. A 0.1uF bypass capacitor is recommended to be placed across the power supply pins to minimize electrical noise.
The RESETb pin is active low. This means that when you connect RESETb to 0V or ground , the device will not operate and all the outputs will be off. For normal operation, RESETb should be connected to the same VDD voltage supply through a 10K ohm 1/4 watt resistor.
This microcontroller has two mode selection pins that allow you to select different modes of operation by simply connecting the MODESEL pins to either power or ground. This allows you to chose different operating modes without having to use a computer or programmer.
Pulling the MODESEL pin to VDD (power) creates a logic 1. Connecting the MODESEL pin to VSS (ground) creates a logic 0.
The following shows the different operating modes depending if you connect the appropriate MODESEL pin to VDD (power) or VSS(ground).
The fireflies will light randomly within the time period specified in the table below. For example 1-15 second delay means that the next firefly can fire anywhere between 1 and 15 seconds after the previous one. So in this case the next firefly can fire as quickly as 1 second later , or as long as 15 seconds later. The time is random but must fall in this range. Setting a long delay will make the fireflies appear less active , setting a short delay will make them appear more active.
MODESEL1 | MODESEL0 | Operating mode |
---|---|---|
VSS (0) | VSS (0) | 1 sec delay |
VSS (0) | VDD (1) | 1-31 sec delay |
VDD (1) | VSS (0) | 1-7 sec delay |
VDD (1) | VDD (1) | 1-15 sec delay |
The 8 firefly LED outputs (Firefly0 to Firefly7) will drive the VDD supply to the LEDS. If you connect VDD to +3V DC , the outputs will drive 3V to the LEDS. If you connect VDD to 5V the outputs will drive 5V to the LEDS.
It is important to select a series resistor for each LED such that the maximum current is limited to less than 20mA. The micorcontroller can handle 20mA per output with a maximum total output of 200mA.
Below is an example circuit showing the typical way to hook up the microcontroller and LEDS. If you choose to remote mount the LEDS, use 22-24ga wire.
C1 is a bypass capacitor that helps to filter out electrical noise in the power going to the microcontroller.
By pulling the MODESEL pins up to VDD via a 10K ohm resistor, you will put a default value of VDD on the MODESEL pin. If you close the switch , it will pull the MODESEL pin to ground (VSS), selecting a different operating mode.
NOTE: The MODESEL pins are only read once when the device first gets power. Switching the value on the MODESEL pins during operation will have no effect. You need to power cycle or reset the microcontroller to select the new mode.
D1 to D8 are the LED firefly outputs. R4 to R11 should be selected to limit the current in the LEDS to less than 20mA.
Click for a larger circuit diagram image.
SW2 | SW1 | Operating mode |
---|---|---|
Closed (0) | Closed (0) | 1 sec delay |
Closed (0) | Open (1) | 1-31 sec delay |
Open (1) | Closed (0) | 1-7 sec delay |
Open (1) | Open (1) | 1-15 sec delay |