loading

In this Instructable I'll show how to create an animal-behaving object, using very simple parts and an Arduino board. The Instructable is intended for people who have some experience with Arduino.

You might want to check this references on animals and Arduino:

http://learn.adafruit.com/adafruit-trinket-modded-stuffed-animal/overview

Servo Motors are super easy to use, you don't need any other components to connect it to your Arduino, besides some jumping wires. Here you can lern more about them: http://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/overview

Step 1: List of Parts

(1x) Arduino Uno
(1x) usb cable
(1x) breadboard
(10x) jumper wires
(1x) small 8 ohm speaker
(1x)10 k resistor
(1x) servo motor
(150x) feathers
(1x) piece of cloth or nylon
(1x) some sphere or any form of Polystyrene to move the feathers
(1x) potentiometer

Optional:
You can add any sensor as input and make it interactive to sound, light, toxic gases, or any other idea you might have!

Step 2: The Code

{{{

//motor
#include <Servo.h>
Servo servo; 

int servoP = 9;
int angulo = 0;
int anguloslow = 0;
int counter = 0;
int counterslow = 0;
int movements = 0;

//piezo
int piezopin =11;  // select the input pin for the speaker

//potentiometer
int potPin = 2;    // select the input pin for the potentiometer
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  //piezo
  pinMode(piezopin,OUTPUT);

  // initialize serial communications (for debugging only):
  Serial.begin(9600);
}

void loop() {

//plays a sound and moves according to potentiometer. Potentiometer returns a number between 0 and 1023
val = analogRead(potPin);    // read the value from the sensor

for(int i = 0; i<5; i++ ){
  
   val = analogRead(potPin);    // read the value from the sensor
    ///maps pot value to angulo (10 to 50) 
   val = map(val, 0, 1023, 20, 50);
   Serial.println(val);  // print potentiometer (for debugging only)
  
   counter = random(2,6);

   angulo = val;
   //moves according to: angulo, normally 10-50. counter: how many times goes back and forth, rormally 3-6. servoP is teh pin
   moveit(angulo,counter,servoP);
   
   //makes the sound according to: intensity, varies: normally 5. number of times: how many times tweets, rormally 3-6
   highChirp(5,angulo/10);
   delay(100);
   lowChirp(angulo*4,2);
   delay(100);
   tweet(counter,2);
   
   //delay between the closer tweets
   delay(400);
    }
   
  //general delay after a series of tweets
  delay(random(20000));
}

void moveit(int anglefin, int movements, int servoPin){
servo.attach(servoPin);

  for (int i=0; i < movements; i++){ 
   
  // scan from 0 to 180 degrees
  for(int angle; angle < anglefin; angle++) 
  {                                 
    servo.write(angle);              
    delay(random(5));   
  }
 

  // now scan back from 180 to 0 degrees
  for(int angle = anglefin; angle > 0; angle--)   
  {                               
    servo.write(angle);          
    delay(random(5));     
  }
  }
  servo.detach();

  }

void highChirp(int intensity, int chirpsNumber){
int i;
int x;

for(int veces=0; veces<=chirpsNumber; veces++){

for (i=100; i>0; i--)
  {
   for  (x=0; x<intensity;  x++)
   {
   digitalWrite (piezopin,HIGH);
   delayMicroseconds (i);
   digitalWrite (piezopin,LOW);
   delayMicroseconds (i);
   }
}
}
}

void lowChirp(int intensity, int chirpsNumber){
int i;
int x;

for(int veces=0; veces<=chirpsNumber; veces++){

for (i=0; i<200; i++)
{
   digitalWrite (piezopin,HIGH);
   delayMicroseconds(i);
   digitalWrite(piezopin,LOW);
   delayMicroseconds(i);
  }
   
  for (i=90; i>80; i--)
  {
   for  ( x=0; x<5;  x++)
   {
   digitalWrite (piezopin,HIGH);
   delayMicroseconds (i);
   digitalWrite (piezopin,LOW);
   delayMicroseconds (i);
   }
  }
}
}

void tweet(int intensity, int chirpsNumber){

int i;
int x;

//normal chirpsNumber 3, normal intensity 5

for(int veces=0; veces<chirpsNumber; veces++){
    
  for (int i=80; i>0; i--)
  {
   for  (int x=0; x<intensity;  x++)
   {
   digitalWrite (piezopin,HIGH);
   delayMicroseconds (i);
   digitalWrite (piezopin,LOW);
   delayMicroseconds (i);
   }
}
}

  delay(1000);

  }

}}}

Step 3: The Schematics

Step 4: The Assembly

I created the animal in the shape of a cage, but you can assembly it as you wish.

You will need to fix the polystyrene shapes to the wings of the motor (make sure you use polystyrene friendly glue for that). Here I show you how does it look inside.

In order to assembly the birdcage, I used a ....

<p>Fantastic :-). I am searching for a long time to make a doorbell with a birdsound. Maybe this is a nice project for me. Very very nice!</p>

About This Instructable

2,899views

8favorites

License:

More by iohanna nicenboim:Make your Arduino sound and move like a Bird 
Add instructable to: