FlatFlap is a compact actuator that can generates organic flappy movements. However this guide focuses on creating a short pulse - a single flap lasting only a few milliseconds before stopping. This method is useful for quick actuation, and applications where brief motion is required.
To generate motion, FlatFlap relies on an electric current passing through its coil, creating a magnetic field. By applying a short pulse, we induce a rapid magnetic field that repels the magnet instantaneously.
To manually generate a pulse you can use basic digitalWrite commands:
#define FLAP_PIN1 2
#define FLAP_PIN2 3
void setup() {
pinMode(FLAP_PIN1, OUTPUT);
pinMode(FLAP_PIN2, OUTPUT);
}
void loop() {
digitalWrite(FLAP_PIN1, HIGH);
digitalWrite(FLAP_PIN2, LOW);
delay(500); // Pulse duration in milliseconds
digitalWrite(FLAP_PIN1, LOW);
digitalWrite(FLAP_PIN2, LOW); // Stop motion
delay(3000); // Stop for 3 sec
}
This simple code sends a 500-millisecond pulse to FlatFlap, causing a brief movement before stopping.
Instead of an abrupt ON/OFF pulse, PWM (Pulse Width Modulation) can gradually control the intensity, reducing mechanical stress and improving performance. This is automatically handled in DriveCell:
#include <drivecell.h>
#define IN1_pin1 2
#define IN1_pin2 3
DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
void setup() {
FlatFlap1.Init();
}
void loop() {
FlatFlap1.Pulse(true, 10); // Pulse forward for 10ms
delay(500); // Wait before the next pulse
}
If you are using our DriveCell library you can directly use the Pulse function to implement this:
#include <drivecell.h>
#define IN1_pin1 2
#define IN1_pin2 3
DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
void setup() {
FlatFlap1.Init();
}
void loop() {
FlatFlap1.Pulse(true, 100); // Pulse for 100ms
delay(3000); // Wait before the next pulse
FlatFlap1.Pulse(true, 1000); // Pulse for 1000ms
delay(3000); // Wait before the next pulse
FlatFlap1.Pulse(true, 500); // Pulse for 500ms
delay(3000); // Wait before the next pulse
}
Understanding the Function:
Pulse(bool direction, uint8_t ms_duration)
direction: true
(north) / false
(south)
ms_duration: Duration of the pulse in milliseconds
Using short pulses, you can control FlatFlap for quick actuation applications. Check out the DriveCell GitHub Repository for more code examples and technical documentation!
Erfahren Sie als Erster von neuen Projekten und sichern Sie sich spannende Angebote!
© 2025 Microbots.