Servo Necktie

For this project, I wanted to create a device that would allow the user to silently show shock and surprise.

Vimeo video in the link below (WordPress won’t seem to let me imbed it).

Servo Operated Tie from Eamae Mirkin on Vimeo.
I soldered a small armature to fit inside a shirt collar, that holds the servo motor in place so that it can lift the tie. The tie is supported by a wire frame, shown connected to the servo with thin copper wide.


/*
* Servo Necktie.
*
* operates a servo motor based on input from a small
* trigger switch
*
*/

#include

// define three different modes
#define NEUTRAL 0
#define TRIGGER_OPEN 1
#define TIE_RAISED 2

// define time delays
#define TRIGGER_DELAY_DURATION_MS 100
#define TIE_RAISED_DURATION_MS 3000

// define tie angles
#define NEUTRAL_POS 180
#define RAISED_POS 40

Servo tieServo;           // initialize servo for tie;
int triggerPin = 2;       // Set the trigger switch to pin 2
int triggerState = LOW;   // The trigger state is defaulted to LOW;
int ledPin = 13;          // Set the led to pin 13

unsigned long timeStamp = 0; // sets the time stamp to zero seconds;
int mode = NEUTRAL;          // set the mode to NEUTRAL

void setup(){
pinMode(triggerPin, INPUT); // set the trigger pin to input
pinMode(ledPin, OUTPUT);

tieServo.attach(9);             // servo is connected to PWM pin 9
tieServo.setMinimumPulse(600);  // 0° = 600
tieServo.setMaximumPulse(2400); // 180° = 2400

//Serial.begin(9600);
//Serial.print("Ready");

}

void loop(){

switch(mode){
case NEUTRAL:
checkTrigger();
break;
case TRIGGER_OPEN:
waitForTriggerDelay();
break;
case TIE_RAISED:
waitForRaisedDuration();
break;
}

Servo::refresh();

}

void checkTrigger(){

//Serial.println("0");

triggerState = digitalRead(triggerPin); // read the trigger state
if(triggerState == HIGH){ // if the trigger is open
mode = TRIGGER_OPEN; // change the mode to trigger open
timeStamp = millis(); // reset the time stamp

//Serial.println("trigger is open");
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
}

void waitForTriggerDelay(){

//Serial.println(1);

triggerState = digitalRead(triggerPin); // read the trigger state
if(triggerState == LOW){ // if the trigger is cloaws again
mode = NEUTRAL; // set the mode back to neutral
}
else if(millis() > (timeStamp + TRIGGER_DELAY_DURATION_MS)){ // if the delay duration has elapsed since the time stamp was set
raiseTie(); // raise the tie
mode = TIE_RAISED; // change the mode to tie raised
timeStamp = millis(); // reset the time stamp
}
}

void waitForRaisedDuration(){

//Serial.println(2);

if(millis() > (timeStamp + TIE_RAISED_DURATION_MS)){
lowerTie();
mode = NEUTRAL;
}
}

void raiseTie(){
tieServo.write(RAISED_POS);
}

 

 

 

void lowerTie(){
tieServo.write(NEUTRAL_POS);
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s