<aside>

About this version: These are the parts I used to upgrade the version 1 prototype into a more compact and wireless version. This version uses a battery and a 2g servo.

STL files will not be for sale this version since it’s a pretty big project for me to make sure it works for everyone’s different setups.

But you can check out version 1 to learn how the gears and mechanisms work to make your own using the new parts in version 2.

Version 1 link: Flapping Butterfly Clip Build Guide v1

</aside>

This guide will give you:

If you’re a beginner and new to building electronic projects, feel free to join my discord and I’ll try my best to answer questions when I can. If you’re an experienced builder, would love for you to share your expertise!

Join the Regine's Digital Cafe Discord Server!

Parts List

Item Quantity Additional Notes
LiPo Battery 1 3.7V 200mAh 30C (only 15 minutes of runtime though, you can use a higher mAh battery as long as it can output at least 2-3W)
Boost Converter 1 5V 2A output TTP
Microcontroller (ESP32 S3 Supermini) 1 ATtiny boards can work, and may remove the need for the boost converter for an even more compact fit
DSpower 2g servo 1 3.7–4.2V model
24 AWG wires as needed
5mm magnets (optional) 8 If you want to add/remove different wings easily, you can add magnets to the base of the wings & gears to snap it on and off
TTP223 touch sensor (optional) 1 touch controls if you want it turned on and off via touch

Tools: Soldering Iron, multimeter, 3D printer to create your own Butterfly wings and hairclip case

Component Connect to
Battery (+) Boost Converter VIN
Battery (-) Boost Converter GND
Boost Converter VOUT ESP32 5V pin
Boost Converter GND Common GND
Servo ground Common GND
Servo input ESP32 GPIO2
Servo power Battery (+)
Touch sensor ESP32 3V3
Touch sensor Common GND
Touch sensor ESP32 GPIO 1

Wiring Diagram

Untitled_Artwork-1 2.png

Code

You can copy and paste the code below into Arduino IDE


#define MAX_EASING_SERVOS 1
#define ENABLE_EASE_SINE

#include "ServoEasing.hpp"

int startPos = 0;
int endPos = 135;
int flapDuration = 1500;
bool wingsClosing = true;
bool powerSwitch = false;
bool lastSwitchState = LOW;
ServoEasing wings;

void setup() {
  wings.attach(1, startPos);
  pinMode(2, INPUT);
  wings.setEasingType(EASE_SINE_IN_OUT);
}

void loop() {
  bool switchState = digitalRead(2);

  if (switchState == HIGH && lastSwitchState == LOW) {
    powerSwitch = !powerSwitch;
  }

  lastSwitchState = switchState;

  if(!wings.isMoving() && powerSwitch) {
    
    if(wingsClosing) {
      wings.startEaseToD(endPos, flapDuration);
    }
    else {
      wings.startEaseToD(startPos, flapDuration);
    }

    wingsClosing = !wingsClosing;
  }
  
  delay(1);

}

Safety Notes

Make it your own!

If you build your own, I’d love to see it! Post your version and tag me, or share it in the Discord to show off what you made. I may even feature some of your builds on my social pages! 💛