Wedding Butterfly





Introduction: Wedding Butterfly

DIY Wedding Challenge

Finalist in the
DIY Wedding Challenge

An interactive butterfly for in your hair!

A friend of mine wants to marry like a butterfly! So she asked me to make an interactive butterfly on a hairpin, to put in it her hair. Is this possible, she asked? Of course this is possible! The biggest problem in hardware was finding a small servomotor, to be fitted on a hairpin.

The other problem in software was programming the ATTINY45 with interrupt and ADC converter (analog PIN) and PWM, for the servomotor. But since I have done that for you (reading and combining codes of others on the internet) you can just upload my code, and make variations.

Then start a production of butterflies and become rich! Because which woman wouldn't be married like a butterfly, there must be an enormous market out there!!!

Step 1: Components

components needed:

a hairpin! (just ask your girlfriend!)

butterfly (you can the ones on the picture at  )

servo motor ( the smaller the better, the smallest I found was at
(There are smaller ones, see the comments!)

ATTINY45 (8 PINS, yes SMD, you can by this at )
3mm LED (or even smaller, in any electronics shop like )
LDR ( Light dependent resistor, under a euro but to be bought everywhere, nothing special)

one resistor of 4.7 kOhm, (small, for combining with the LDR)
some perspex, (for putting the butterfly above the servo motor)
some thread, (to get the movement from the servomotor to the wings)
some wire, for attaching the components
some PCB with copper you can cut with a knife, for mounting the ATTINY45 without EAGLE (although you can do this properly too of course)
batteries (total around 3V), so no extra resistors for the LED's are required
some paint used for models, making the hairpin and components disappear in the lush hair of the bride

Some components I had to buy especially for the butterfly were the glue and the polyester thread. (glue 3 euro, thread 60 cents on a local market)

Step 2: Tools

tools needed:

soldering device, to mount the ATTINY on the PCB and solder the wires
programmer, (sorry, no other way to program the ATTINY45, this is not an ARDUINO)
(laptop with AVR Studio, AVR Studio is free!)
fine saw, for the PCB and the perspex
knife (for cutting the PCB, the wires)
tweezers(for positioning the ATTINY45 )
fine rasp (for the PCB and the perspex)
Voltage/resistor meter, (always testing with hardware)
glue gun, (for attaching the servomotor on the hairpin and attaching the LDR, LED and wires)

Step 3: Preparing the Butterfly

My bride has given me the cloth of her wedding dress to make the wings of the butterfly correspond to her dress. But here we just use a plastic butterfly. You have to cut the wings a little bit at the base to get them as pliable as possible.

She tried to stiffen the cloth using textile glues or something, but the results were not too good. She copied the dress butterfly design on transparent sheet and that was perfect, see pictures. The transparent sheet is also bending quite well.

Reassemble the butterfly.
Glue some wires (thread, the best is transparent fishing thread) to the middle of the wings, these wires will go to the lever of the servo motor.
I have put some glue on top of the butterfly, between the wings to get the wings standing right up. This is all a bit experimental and your butterfly can ask for other solutions.

Make the perspex about 1 cm high and give it half the length of the butterfly. (Also depending on the size of the servomotor.)

Step 4: Preparing the ATTINY45

This is the tricky part, where you find out that your fingers are way too big!
Cut three lines next to each other on the copper of the PCB.
Cut a thick line right across it in the middle
Make sure with the voltage meter that the copper strips are not connected anymore.

Position the ATTINY45 on the copper strips
Solder the thin wires to the PINS like this:
  • LED: PB3 (and GND)
  • LDR: PB2 (and VCC)
  • resistor: PB2 (and GND)
  • Servo motor: PB1 (and VCC and GND)

Ok, than do not forget to connect the six wires on for the programmer:
  • MOSI: PB0
  • MISO: PB1
  • SCK: PB2
  • RESET: PB5
  • and GND and VCC

(see of course the datasheet of ATTINY45)
I have added an Eagle like schematics.

My programmer is AVRISP mkII, which means the MOSI, MISO SCLK, together with RESET VCC and GND connections are used. I use a connector for that like the drawing.

Step 5: Making the Butterfly

This is a process of careful gluing. First I used a glue gun, but that was too crude.
Then a "seconds" glue. Of course I glued my finger to the table!

Also I bought polyester thread, which is transparent and barely visible for the wings.

The wings have to be glued against the body of the butterfly to be in a rather vertical normal position.

On the chip side you have to keep the wires as short as possible. I leave the programmer cable connection on as long as possible to be able to make small changes to the performances of the butterfly.

Step 6: The Battery

Very important in this kind of small interactive things is the voltage and the battery.
Where can a bride hide the batteries?
How much batteries is a bride prepared to carry around dancing?

I found a nice rechargeable battery pack at sparkfun:

As you can see on the picture it is very thin, you have to buy the charger too.
We have to check the time it will feed the butterfly!

But you can do it using two small AAA batteries too.

This bride will not have the batteries in her dress (as I proposed) she will carry the batteries hidden in ...
... her hair! (That is what we call a "coiffure"!)

Measuring the voltage of the rechargeable: 4.2V, this is too much for the servomotor :-(
So I'll try two or three coin cells, which are even smaller.

In the end I decided to make a special butterfly casing, which you can see in the second picture of this step. It is made of perspex which you can mold and shape by heating it up. Quite a job though, for a simple casing! But this has to be carried around in the hair (coiffure!) of the bride. So a bit of attention to the design (you recognize the butterfly?) is not wasted.

Step 7: Software (AVR Project)

For the software, you need to upload it using the programmer.
The program is not very big it all fits easily within 2K!

The program is certainly not very big:
Device: attiny45
Program: 834 bytes (20.4% Full)
(.text + .data + .bootloader)
Data: 21 bytes (8.2% Full)
(.data + .bss + .noinit)

software you need:
download my code, hack it, modify it!

The code has several parts:
  • initializing the analog ports for the LDR, for flapping at a flash or fast light change
  • initializing  timer 1 for the flapping, and not forgetting to flap once in a while
  • initializing  timer 0 for the PWM, servomotor
You can change the number of times if flaps, the speed, the degrees of flap....
make it as much a living butterfly as possible!

Step 8: Finishing

Servo motor:
The servo has two sides! Choose the right one. You will see with testing that it returns to its base position starting up. This movement should not make a hole in the nice head of the bride! (Eventually you can fix the limits of the movement in the script.)

Better to test the performance before glueing all together!
If the servomotor, and later on the whole butterfly clasps it wings regularly, and also when the light is changed, (flashing can do the job too) than all is right.

Glueing it together and giving it a paint.
When you are satisfied testing, than carefully adjust the wires, so that no wires stick out, and they are as short as possible. Choose the positions for the LED and the LDR on the hairpin, depending on its shape and length. Glue everything on the hairpin.
Where to put the battery? My idea was at the back of the dress, but my bride said NO! In my hair somewhere!!!
So I have chosen the smallest possible batteries to be fitted in some curl of her hair…

The butterfly wedding will be at the end of august!



    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Spotless Contest

      Spotless Contest

    We have a be nice policy.
    Please be positive and constructive.




    Hi pintoc2!
    Better late than never...:-)
    The LDR is just a cheap one, less than one euro:
    range between 2K in light and 1000K or more in the dark
    The resistor is a "balance" for the LDR. Normally 2K - 5K, depending a bit on the ambient light you experience.
    The chip is running on around 3V, the number of batteries are your choice: the more (in parallel) the longer the butterfly stays alive.
    The essence of the circuit is the LDR giving the analog input and the reaction of this signal in the servomotor.
    You can try first with a "big" attiny45 on a breadboard, (programmable now with the Arduino IDE), or even an Arduino. LDR and a servo. For me the problem was to get it as small as possible.
    ok, hopes this helps!

    I've made several attempts at making this and have yet to get one that works. Has anyone other than the author completed this project and gotten it to work? The author seems un-willing to give any further information.

    You only mention one (1) resistor in all of your instructions yet your photos show two (2) one large one at the top of your circuit board. what is it and what is it connected to. Also your instructions say connect resistor to PB2 and GND yet the schematic shows PB2 and VCC. which one is correct?

    A couple of questions. Does it matter what the rating of the LDR is? and it looks like you are using a total of 8 batteries is that correct or are there only 4?

    Very pretty. Just hope nobody tries to be helpful and shoosh the butterfly off your head! ;-O) 5 stars!

    Awesome application. How did You program the ATtiny45?.

    relly cool, you really can trick the people with this

    Hobbyking has a servo a bit less then half the weight of the one you've got linked. It's design looks like it might work better as well:

    Just in case the link doesn't work it's titled "HobbyKing Ultra Micro Servo 1.7g for 3D Flight (Right)".

    It comes in right- and left-hand versions so I suppose you'd have to give that some consideration.

    Thx great, although for this wedding it will be too late...there are minus 9 items in stock! But i''l come back to the link....

    Pretty cool.
    I'd like to have a go at building this, but with zero background in electronic engineering a lot of the wiring instructions for the ATTINY and so on are gobbledegook. How about a nice, easy-to-follow line diagram and circuit?
    I'm sure the lovely bride will look amazing!