Wednesday 21 August 2013

Whistle and Wag!

 Detect sound generated by

 Buccal Wetware

 [brain; purse lips; exhale; whistle]


A very simple and Fun Hack for Whistle and Find Device


Introduction.
This is a fun hack for those whistle and find devices. The type you attach to your remote control so you can always find it eg whistle and find device.

That ones quite expensive, but you can often find them on offer in bargain shops for a couple of quid. I bought a set years ago and had one left rattling around in one of my junk drawers. I decided to play with it because I was looking for a way to add an interactive waggy-tail to a small robot.

You also need a small servo, arduino (or similar) a photo-resistor and a 10K pull down resistor - simple!

Whistle-n-Wag Circuit

Place the led of the device right next to the sensor surface of the photo-resistor and shade it.
When you whistle the device flashes it's led and that light is picked up by the photo-resistor, this makes a circuit with the 5v supply and this voltage is detected by the analogue pin of the arduino. The video is not good quality but you can get the gist. NB you can use the whistle hardware provided with the sets, but notice I used buccal wetware to generate the sound in the video [brain->purse-lips->exhale = whistle] : )

Whistle-n-Wag Video

Arduino Code:
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
  myservo.attach(7);
  myservo.write(90);
  Serial.begin(9600);
}

void loop()
{
 int lightLevel = analogRead(lightPin); //Read the
                                        // lightlevel

if (lightLevel > 450)
 {
   wag = 1;
 }

 if (wag == 1)

 {
  
   for (pos = 0; pos < 180 ; pos +=2)
   {
  

   myservo.write(pos);

  Serial.println(lightLevel);
   }
  
 }


}

2 comments:

  1. Do you have to be able to whistle? Can it recognise other programmed sounds?

    ReplyDelete
    Replies
    1. Many thanks for the question, gdwiles. Sorry, because it is a pre-made part from the whistle-and-find it recognizes a sound like a whistle. I did a quick search on hackaday and found some others such as voice recognition eg http://hackaday.com/?s=sound+recognition.

      Delete