Project Two: Interactive Wearable!

The following project is on an interactive wearable. The images are from the bunny ears that react to sound.

The materials used are

  • Headphones
  • Servos
  • Bunny Ear Headband
  • Mic
  • Ardurino Trinket Pro
  • Cables
  • Alligator Clips
  • Plastic Rectangles  
  • Mini Bread Board
(Trinket)

 (Mic)

 (connecting the pieces)

(end product)

 (Without Duck)

(The underview)
The code that was used is:
/*
  Make a Servo Move to Sound.
   This example code is in the public domain.
   2012 by Cenk Özdemir
*/
// for servo stuff we include the servo library
#include <Servo.h>
// creating a servo object
Servo myservo;
// Some Varuables we need
int ServoPin = 9;
int SoundInPin = A0;
int LedPin = 12;
int servoValue;
// the setup routine runs once when you press reset:
void setup() {
  // initialize
    myservo.attach(ServoPin);
     pinMode(SoundInPin, INPUT);
     pinMode(LedPin, OUTPUT);
     Serial.begin(9600);
       myservo.write(0);
}
void loop() {
  int sensorValue = analogRead(SoundInPin);
  // We Map it here down to the possible range of servo moovment.
  //sensorValue = sensorValue -330;
// Serial.println(sensorValue);
  sensorValue = map(sensorValue,486,150,1,180);
   // constrain(sensorValue, 0, 300);
    sensorValue = abs(sensorValue);
   // delay(100);
 // Serial.println(sensorValue);
myservo.write(1);
  // setting the servo into standard position
  int MoveDelayValue = map(sensorValue,0,255,0,sensorValue);
  // maping the same reading a little bit more down to calculate the time your servo gets to make the one Move
myservo.detach();
if (sensorValue > 50 && sensorValue < 200) { // to cut off some static readings only if the reading gets higher then 33 it begings to work
myservo.attach(ServoPin);
//threshold for jittering
   delay(10);  // a static delay to smooth things out…
   servoValue = map(sensorValue,3,80,1,180);
    constrain(servoValue, 0, 180);
// now move the servo to our mapped reading
//  Serial.print(“servoValue: “);
//  Serial.println(servoValue);
  myservo.write(sensorValue); 
  delay(15);  // a static delay to smooth things out…
         // and do that move in this delay time
  
  delay(MoveDelayValue); 
//}
// else { myservo.write(0);
//}
}