Thread Tools
Oct 25, 2016, 12:24 PM
Registered User

Arduino Servo Flap System

Here is my Arduino servo-flap system. I don't have a model designed for it yet, I just wanted to post a video since people are talking about these systems again.


Arduino Based Servo Flap Ornithopter (1 min 50 sec)
Sign up now
to remove ads between posts
Oct 25, 2016, 12:26 PM
Registered User
Here is the Arduino source code. I'm using an Arduino Pro Micro 5V 16MHZ system:


//Arduino servo flap system
//copyright Steve Morris 10-25-16
#include <Servo.h>
volatile int pwm_value = 0;
volatile int prev_time = 0;
static int servo_comm1 = 0;
static int servo_comm2 = 0;
volatile int flapangle1 = 0;
volatile int flapangle2 = 0;
volatile int millisold = 0;
int millinow= 0;
float dt=0;
float flapmag = 0;
static float flapdeg = 0;
float tcommand = 0;
float floattime=0;
float temp=0;
float glide_deg = -10.0;
static int pwm_value_temp = 0;
float omegadot=0.0;
float thetadot=0.0;
static float omega=0.0;
static float theta=0.0;
static float k0=1.0;
static float k2=10.0;
static float servo_zero1=-4;
static float servo_zero2=0;

Servo myservo1, myservo2; // create servo object to control a servo

void setup() {
// when pin D2 goes high, call the rising function
attachInterrupt(0, rising, RISING);
myservo1.attach(5); // attaches the servo on pin 5 to the servo object
myservo2.attach(6); // attaches the servo on pin 6 to the servo object
void loop() {



flapdeg=flapmag*sin(theta);//variable amplitude+freq

flapangle2=(int)((30.0+flapdeg+servo_zero2)*2.0+25 .0);

if (pwm_value > 930){
servo_comm1 = flapangle1;
servo_comm2 = flapangle2;

//Glide Lock
if (pwm_value < 910){

servo_comm1 = (int)((30.0-glide_deg+servo_zero1)*2.0+25.0);
servo_comm2 = (int)((30.0+glide_deg+servo_zero2)*2.0+25.0);


myservo1.write(servo_comm1); // tell servo to go to position in variable 'pos'
myservo2.write(servo_comm2); // tell servo to go to position in variable 'pos'



void rising() {
attachInterrupt(0, falling, FALLING);
prev_time = micros();

void falling() {
attachInterrupt(0, rising, RISING);
pwm_value = micros()-prev_time;
Oct 25, 2016, 05:25 PM

Awesome work!

I don't see in the code where you invert the signal from one servo to another. Are both of the servos standard rotation direction?
Oct 25, 2016, 06:29 PM
Registered User
Originally Posted by CosmicDog
I don't see in the code where you invert the signal from one servo to another. Are both of the servos standard rotation direction?
It all happens with a minus sign here:

servo_comm1 = (int)((30.0-glide_deg+servo_zero1)*2.0+25.0);
servo_comm2 = (int)((30.0+glide_deg+servo_zero2)*2.0+25.0);

and here

flapangle2=(int)((30.0+flapdeg+servo_zero2)*2.0+25 .0);

Last edited by mlbco; Oct 25, 2016 at 07:08 PM.
Oct 25, 2016, 08:55 PM
thank you, I missed that in the code . I am in the processes of setting up a similar test bed. I will be using the Teensey development system instead of aurduino. Great Work!
Oct 26, 2016, 01:55 AM
Registered User
I decided to start building the wing assembly. I don't use plans, I just build as I go so I don't even know what this thing will end up looking like. At the moment each servo is flapping a 4 ft carbon tube (3/16" OD). It looks like the max flapping rate with these spars is just over 1HZ and +- 25 deg. The video shows it flapping at near maximum rate and amplitude with just the spars.

Spar flap test (0 min 16 sec)
Oct 26, 2016, 02:37 PM
Registered User
Steve here are few people who have respected me (over the time spent here) with their ideas , what they have done and what they write . You are one of them.
Thanks for all you have posted here.

When comes to servo powered ornithopters our opinions are different .Mainly because the inability of RC servos to work long enough as ornithopter drives and doesn't matter is the servo brushless ,with contactless encoder and energy recuperation the efficiency of such wings drives is owful.
This corrupt the main goal of ornithopters - the efficiency of flight so that's why I'm against that and everything without common sense as hybrid ornithopters with proppeler,ducted fan or turbines. And please every body don't get me wrong . I'm not negative just looking for common sense and objectiveness.
Yes I agree that there are a lot of pros which you even didn't use as pitching, rolling and yawing the ornithopter by assimetric wing flapping .Nathan and Gupta's people doing that btw .Nathan's one even doesn't have any tail servos everything about the control is done by manipulating the wings' motions .
Although yours servo powered ornithopters flies the best of all similar because of the weight and wings loading and of coarse the construction . I beleave yours are with the heaviest wing loading but the last one even shorten further the servos life .
Here is one of your posts about longetivity of servos used as ornithopter drives.
Please enlighten the people a litle bit more about what they have to expect as servos life in such application ,since the capable servos are in the range of $100-$300 per piece!
Thanks in advance !
Oct 26, 2016, 03:29 PM
Registered User

I don't expect these servos to last! Unless the MKS HV777's have some "magic" in them that the Futaba's lacked, they'll probably die a horrible death too. There are some interesting aspects of a servo flapper that I wanted to play around with about 1.5 years ago and that's when I bought these servos. Since I still had them sitting in a box I decided to start this project, this was not a new revelation for me regarding servo longevity. The hardware is already "dead" to me, I just need to spend my time building something with it!

I have built many ornithopters that took long hours to build only to see them in the air for barely a few minutes (seconds?) before they stopped working or were destroyed. I'm not concerned about burning up these servos if they let me get a few good flights in. My last servo powered ornithopter probably had less than 15 decent flights on it before I lost a few hundred $$ worth of electronics when the servos died. Either way, I learned a lot. It's a masochists hobby to say the least.


Oct 26, 2016, 03:36 PM
Registered User
Thanks a lot Steve ! Appreciate your objective reports!
Oct 27, 2016, 01:30 AM
Registered User
I built the main spar support structure from carbon tubes lashed with carbon fiber tow and bonded with thin Super Glue. The airfoil shown is a template for the shape I'm planning to use. The wing will have several ribs attached to the main spar with wash-in and the covering will be a single piece of Coverlite on the upper surface only. The plans are a sketch of what it might look like, but I'm designing as I build so anything could happen.

Oct 29, 2016, 12:40 AM
Registered User
I decided on a wing rib structure made from 1/4" balsa and carbon strips. I made a set of ribs and then installed them with linearly increasing washin up to 15 deg at the tip. Hopefully the main spar will flex 15 deg at 1-g load and my twist in glide will be close to zero.

The trailing edge is a piece of nylon string and next I'll cover the upper surfaces with CoverLite.

Oct 29, 2016, 07:27 AM
Registered User
therealthing691's Avatar
Very creative stuff Steve and very light great stuff regards Brian
Oct 29, 2016, 01:17 PM
Registered User
The wings are covered and I did my first flapping test. The video shows that as flap rate increases above a certain value the flapping amplitude decreases because the servos can't keep up. I'm trying to keep the model's weight no more than 1 lb and hopefully it will fly. The good news is that the servos don't get warm during these tests. The wingspan is 70".

Wing Flapping with MKS HV777 Servos (0 min 30 sec)
Oct 29, 2016, 10:30 PM
Registered User
Fuselage is coming together from sheet balsa. Wing assembly drops in but will be glued in soon.

Oct 30, 2016, 02:43 AM
Registered User
The tail is framed and the fuselage is getting sheeted.


Quick Reply

Thread Tools