Pages: [1]   Go Down
Author Topic: Whistle and Wag! Fun hack for whistle and find device.  (Read 1221 times)
0 Members and 1 Guest are viewing this topic.
Durham UK
Offline Offline
Full Member
Karma: 1
Posts: 169
aka Craig Turner
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

These devices have a small led that flashes and a beep when you whistle. I had one left over knocking about the house, so I wanted to find a use for it. They are about 3 x 3 x 1.5 cm and run off a couple of button cells. You don't need to use the plastic whistle to work it, you can use purse your lips and do it yourself - needs to be loud though.

I hooked one up to flash onto an LDR so when you whistle a signal goes via analogue pin to start a servo and wag a piece of wire. Easy way to add an interactive
wagging tail to your robot! The LED is placed right next to the LDR and the whole lot is shaded from ambient light.



Servo myservo;
int wag = 0;
int pos;
//PhotoResistor Pin
int lightPin = 0;

int servopin = 7;   //the pin the servo is connected to
void setup()
  pinMode(servopin, OUTPUT); //sets the servo pin to output
  digitalWrite(servopin, LOW);  //servo OFF
void loop()
 int lightLevel = analogRead(lightPin); //Read the
                                        // lightlevel

if (lightLevel > 450)
   wag = 1;
 if (wag == 1)
   for (pos = 0; pos < 180 ; pos +=2)


I put in serial for debugging. You need to play around with what light level you need to trigger the wagging. Also your LDR may vary from mine. See video.

Would welcome some feedback for improvements, additional actions etc..


* whistle-n-wag.gif (6.28 KB, 720x687 - viewed 24 times.)
« Last Edit: June 10, 2012, 12:24:56 pm by trendski » Logged

Craig Turner, blog: It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

Pages: [1]   Go Up
Jump to: