The FlatFlap is an incredibly thin and innovative actuator that brings motion to your projects in a compact form factor. To understand how it works, let's dive into its unique design and the principles behind its operation.
In this tutorial we will explain:
What is a FlatFlap?
It's Flat and its a Flap ~ the FlatFlap is an actuator made from a flexible PCB (printed circuit board) and aluminum stiffeners, folded together to create a low-force flapping motion. It’s magnetic system converts electrical energy into mechanical movement.
How Does It Work?
The FlatFlap features a thin 10mm N52 neodymium magnet on its back, which interacts with the planar copper coil embedded within the flexible PCB. When an electric current passes through the coil, it generates a small magnetic field that either attracts or repels the magnet, causing the flap to move. By alternating the direction of the current, you can control the flapping motion of the actuator. Applying a square wave signal makes the FlatFlap flap continuously, with speeds of up to 25Hz. For smooth organic motions, we will explore the DriveCell PWM library.
Installing FlatFlap
The FlatFlap design makes it easy to install. It comes with a peelable adhesive back and optional M1.2 screws (included) for added security, ensuring that it stays firmly attached to any surface, whether smooth or textured. The adhesive is 3M467, which provides a strong bond but can be removed with tweezers if needed.
Getting Your FlatFlap Moving
If you purchased the FlatFlap as a stand-alone actuator, you can start by pulling one of its pins to 5V and the other to ground, then switch them around. In one instance, the flap will be repelled, and in the other, it will be attracted. You can connect it to your own transistors or H-bridge module to switch these pins automatically. However, to make it even easier, you can purchase the FlatFlap directly soldered to our tiny DriveCell module. The DriveCell is a compact, pin-to-pin compatible H-bridge driver that simplifies the process of controlling actuators like the FlatFlap. Its open-source Arduino software library makes actuator control easy, especially for beginners, by providing straightforward software functions and easy-to-follow examples.
For an in-depth guide on the DriveCell Software Library, check out this article. But here’s a quick recap of how you can use its functions to enhance the FlatFlap actuation. Don’t worry, it’s quite simple! Start by downloading the "DriveCell" library from Arduino's Library Manager. Once installed, you’ll be ready to control your device. Before we start, make sure you connect the DriveCell to your microcontroller. We recommend using a CodeCell, which is pin-to-pin compatible, supports all the library functions, and can add wireless control and interactive sensing to your FlatFlap.
1. Init()
First we need a basic setup code to get you started:
#include <DriveCell.h> // This line includes the DriveCell library
DriveCell myFlatFlap(IN1, IN2); // Replace IN1 and IN2 with your specific pins
void setup() {
myFlatFlap.Init(); // Initializes your DriveCell connected to a FlatFlap
}
This code gives the name 'myFlatFlap' to your DriveCell and tells it to start up and initialize all the necessary peripherals.
2. Pulse(bool direction, uint8_t ms_duration)
This function sends a brief burst of power to the FlatFlap in a specified polarity. This quick energizing and de-energizing can cause a short, sharp movement of the FlatFlap, depending on the polarity.
myFlatFlap.Pulse(1, 10); // Sends a short burst for 10 milliseconds in the specified direction
2. Buzz(uint16_t us_buzz)
This function makes the FlatFlap vibrate like a buzzer, which is useful for creating audible feedback.
myFlatFlap.Buzz(100); // Makes the FlatFlap buzz with a 100 microsecond pulses
3. Tone()
The Tone
function makes the FlatFlap play a tone. This can be used for audible feedback or creative applications where sound is part of the interaction.
myFlatFlap.Tone(); // Plays a tone by varying the frequency
4. Toggle(uint8_t power_percent)
This function switches the FlatFlap direction, which can be useful for creating a rapid flapping movement or reversing direction quickly in your code.
myFlatFlap.Toggle(100); // Toggles direction at 100% power
5. Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)
This function allows you to continuously flip the polarity of the FlatFlap and control its motion speed and smoothness. If smooth
is set to true
, the flapping will be less sharp and smoothed, which is ideal for slower, controlled movements.
myFlatFlap.Run(true, 50, 1000); // Runs the FlatFlap smoothly at 50% power, flipping every 1000 milliseconds
6. Drive(bool direction, uint8_t power_percent)
This function lets you control the FlatFlap polarity and angular position of the flap by adjusting the power level, basically adjusting how strong the magnetic pull or push is.
myFlatFlap.Drive(true, 75); // Moves the FlatFlap forward at 75% power
Here's an example where we configure two FlatFlaps and flap them at different speeds:
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
DriveCell FlatFlap2(IN2_pin1, IN2_pin2);
uint16_t flap_counter = 0;
void setup() {
FlatFlap1.Init();
FlatFlap2.Init();
FlatFlap1.Tone();
FlatFlap2.Tone();
}
void loop() {
delay(1);
flap_counter++;
if (flap_counter < 2000U) {
FlatFlap1.Run(0, 100, 100);
FlatFlap2.Run(0, 100, 100);
}
else if (flap_counter < 8000U) {
FlatFlap1.Run(1, 100, 1000);
FlatFlap2.Run(1, 100, 1000);
} else {
flap_counter = 0U;
FlatFlap1.Drive(0, 100);
FlatFlap2.Drive(1, 100);
delay(500);
FlatFlap1.Drive(1, 100);
FlatFlap2.Drive(1, 100);
delay(500);
FlatFlap1.Drive(1, 100);
FlatFlap2.Drive(0, 100);
delay(500);
FlatFlap1.Drive(1, 100);
FlatFlap2.Drive(1, 100);
delay(500);
FlatFlap1.Drive(0, 100);
FlatFlap2.Drive(0, 100);
delay(500);
FlatFlap1.Drive(1, 100);
FlatFlap2.Drive(1, 100);
delay(500);
FlatFlap1.Tone();
FlatFlap2.Tone();
}
}
Combining with CodeCell Sensors
To make it even more interactive you can combine the FlatFlap and DriveCell with the tiny CodeCell Sensor Module. CodeCell is pin-to-pin compatible with DriveCell, supports all library functions, and adds wireless control and interactive sensing to your project. This allows you to create more advanced, responsive elements with your FlatFlap actuators.
With this next example the CodeCell controls two FlatFlap that stops flapping when proximity is detected. Their angle gets adjusted dynamically based on how close your hands gets.
#include <CodeCell.h>
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
DriveCell FlatFlap2(IN2_pin1, IN2_pin2);
CodeCell myCodeCell;
void setup() {
Serial.begin(115200); /* Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial. */
myCodeCell.Init(LIGHT); /*Initializes Light Sensing*/
FlatFlap1.Init();
FlatFlap2.Init();
FlatFlap1.Tone();
FlatFlap2.Tone();
}
void loop() {
if (myCodeCell.Run()) {
/*Runs every 100ms*/
uint16_t proximity = myCodeCell.Light_ProximityRead();
Serial.println(proximity);
if (proximity < 100) {
FlatFlap1.Run(1, 100, 400);
FlatFlap2.Run(1, 100, 400);
} else {
proximity = proximity - 100;
proximity = proximity / 10;
if (proximity > 100) {
proximity = 100;
}
FlatFlap1.Drive(0, (proximity));
FlatFlap2.Drive(0, (proximity));
}
}
}
Feel free to tweak the code with your own creative ideas, or add motion sensing for a new reaction! With FlatFlap, you can bring your creative projects to life with motion in a sleek, compact package. Whether you're adding dynamic elements to art, experimenting with robotics, or developing interactive mechanical displays, the FlatFlap provides a versatile and easy-to-use solution. Get started today with our Arduino libraries! If you have any more question about the FlatFlap feel free to email us and we will gladly help out!
Be the first to know about new projects and get exciting deals!
© 2024 Microbots.