Adding Microphone and LED

    Circuit for Ollie 

  1. Power the Electret mic through Arduino Uno as shown in circuit diagram using 2 resistors of 3.9Kohm and 4.7Kohm. Control wire should be plugged into analog pin 2 of Arduino.
  2. DSC_0315

  3. Connect LED to digital pin 13 on Arduino Uno.
  4. Make sure all connections are secure.
  5. Resistors are used to increase the amplification of the signal received from the Electret mic and should be wired correctly.
  6. Run this simple program to make sure input is being received. LED will light up whenever a certain threshold of volume is reached. This threshold should be set to a normal or loud talking volume.
  7. int buffer = 0;
    //Sound variables
    int potPin = 1;    // select the input pin for sound sensor
    int ledPin = 13;   // select the pin for the LED
    int soundVal = 0;
    void setup()
    {
      pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
      Serial.begin(9600);      // open the serial port at 9600 bps:
    }
    void loop()
    {
        //Sound
        soundVal = analogRead(potPin);
        //Serial.println("Listening............");
        if( soundVal>1020 ){
          Serial.println("VERY LOUD!");
          digitalWrite(ledPin,HIGH);
         }
        else if (soundVal<450 || soundVal >750){
          if (buffer == 0){
            Serial.println(soundVal);
             buffer = 15;
             digitalWrite(ledPin,HIGH);
          }else{
             buffer--;
          }
        }
        else{
           digitalWrite(ledPin,LOW);
         }
    }
    
    
  8. If the circuit is not working play with the values in the program and make sure resistors are wired correctly.
  9. If the circuit works, wire everything up according to the circuit diagram. Attach toggle switch and LiPo battery to the circuit. Solder all the wires directly to each other and secure with hot glue.
  10. DSC_0371

  11. Upload the final Arduino sketch given below to the Pro Mini using FTDI cable or breakout board.
  12. 
    #include <SoftwareServo.h>
    SoftwareServo myservo;  // create servo object to control a servo
    SoftwareServo myservo2;
    int goUp = 0;
    int val = 0;
    int wait = 0;
    int flyFor = 0;
    long flapTime = 0;
    int angleMin = 0;
    int angleMax = 120;
    int upSpeed = 20;
    int downSpeed = 1;
    int buffer = 0;
    //Sound variables
    int potPin = 1;    // select the input pin for sound sensor
    int ledPin = 13;   // select the pin for the LED
    int soundVal = 0;
    void setup()
    {
      pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
      myservo.attach(2);  // attaches the servo on pin 2
      myservo2.attach(4);
      Serial.begin(9600);      // open the serial port at 9600 bps:
    }
    void loop()
    {
      // Servo
      if (flyFor < flapTime){
        if (wait == 5){
          if (val < angleMin){
            goUp = 1;
            digitalWrite(ledPin,HIGH);
            }
          else if (val >angleMax){
            goUp = 0;
            digitalWrite(ledPin,LOW);
          }
          if (goUp == 0){
            val-=upSpeed;
          }else {
            val+=downSpeed;
          }
        }
        wait++;
        if (wait > 200)
          wait = 0;
        myservo.write(val);
    // sets the servo position according to the scaled value
        myservo2.write(120-val);
        SoftwareServo::refresh();
        flyFor++;
      }else{
         //Sound
        soundVal = analogRead(potPin);
        Serial.println("Listening............");
        if( soundVal>1020 ){
          Serial.println("FREEAK OUT!");
          upSpeed = 15;
          downSpeed = 15;
          angleMax = 45;
          angleMin = 10;
          flapTime = 6000;
       }
        else if (soundVal<450 || soundVal >750){
          if (buffer == 0){
            Serial.println(soundVal);
            upSpeed = random (1, 20); //1 to 30
            downSpeed = random (1, 30);// 1 to 30
            angleMax = random (110, 120);
            angleMin = random (30, 45);
            flapTime = 10000 + random (5000 , 10000);
            flyFor = 0;
            buffer = 15;
          }else{
             buffer--;
          }
        }
      }
    }
    
  13. Solder connections to the Arduino Pro Mini very carefully according to the circuit diagram.
  14. DSC_0359

  15. Attach circuit to bottom of balloon using small amount of foil or tape.
  16. At this point circuit will be light enough to be lifted by the balloon or just the right weight to keep it in equilibrium. Adjust with a small amount of clay if circuit is too light.
  17. DSC_0376

  18. Ollie is ready to fly. Turn the switch on so Arduino Pro Mini is powered with the battery. Ollie will flap his wings whenever he hears you talk or a loud sound is made. Ollie will randomly burst into flight and bring happiness and joy in the life of many.

Continue to Tips for Pro Users