Flag-waving, without use of arm muscles

Eben met Alex from RasPi.tv earlier this week, and was given this rather fantastic flag-waving kit for our demo table. (If you’ve got something you think we could use in demos at schools, in talks, and when we chat to the press, give me a shout at liz@raspberrypi.org – we’re always looking for new kit to show off.)

This demo is something you can very easily set up yourself at home, if you’re interested in learning how to use servos. Alex’s setup means you won’t require any expansion boards – you’ll be ready to go with just a servo (very cheap from your local electronics shop – Alex’s cost him £3), some wire, some batteries and a few bits of wood.

And a flag.

Instructions are at RasPi.tv – if you make your own, please send us some video!



Thanks Liz. :) Hope you had a good flight.

Someone just asked if it’s possible to eliminate the battery box and power the servo from the Pi.

In theory it might be possible, but I wouldn’t do it because servos draw quite a lot of current when starting up. And if you stall the servo, by resisting the flag, it’ll probably force the Pi to reset (or worse). So the answer is, sadly, no. Not practical.


I had tried this previously running it from the 5V, it did work although you get instant reset when you connect it, if the RPi is powered on.

Would recommend sticking to separate supply as suggested, particularly if physically driving anything with the servo.

Hopefully the PWM drivers will get into the latest builds (if can be done without effecting the audio). I found the Occidentalis a little behind the latest Raspbian images now.


Looks like you are trying so set the position too many times and causing jitter… most servos tolerate big differences between signals and you don’t have to wait until it gets to the targeted position before setting another one, you could probably make the same motion with only 2-4 target positions with a few ms between them


That’s worth investigating thanks. I’d actually assumed it was the opposite problem of insufficient resolution. It just so happens I have a spare servo and battery box. Now where did I put those batteries? ;)

I’ve just checked the arduino sweep sketch (which I use on the ATMega versions which run visibly more smoothly on the same rig) and they use the same resolution – 1 degree and the same delay timing – 15ms.

I will try your suggestion of fewer commands and longer waits though because it might just work. Thanks :)


Once the servo gets to the correct position it stops (the whole point of a servo), on a arduino you can order a move, wait little time and give the next order before the servo gets to the correct position. On a non realtime OS timings may become an issue, as the 15ms wait between commands you are mentioning is affected by what is happening on other processes, this gives time to the servo to get to the target position and hence stop


Worth investigating for sure, but the issue may be that because of the non-realtime OS, the timings for the servo pulse (rather than the delay between pulses) may not be consistent enough, so even though you think you’re telling the servo to move to angles 56,57,58,59 the timing inaccuracy means that what the servo receives looks more like 57,56,57,59 ?
Just a guess – I currently don’t have the equipment needed to investigate this myself.


I suppose I could find out by scoping the port 18 output and the ATMega pwm output and comparing the traces. Hadn’t thought of that. :)


“But it does use ARM muscle,” says a chap named Luke on Google+ with just my kind of sense of humour. (I couldn’t possibly spare you.)


Can you run two flags from one Pi?
And a second Pi with a camera, watching the flags?
Wireless communication via semaphore!


If you made a Y-lead from the PWM port, I guess so, but they’d only be able to move the same (or opposite if you turn one round).

Leave a Comment

Comments are closed