Browse files

Mouth servo adjustments

Make close and open routines to make it easier to switch between write
and writemicroseconds.  attach before rise and detach after lower to
reduce servo motor wear.
  • Loading branch information...
1 parent 3067a3d commit c3b2f82591be991d56c89920fd7b1c1751c40d41 @cgrote714 committed Oct 4, 2012
Showing with 33 additions and 10 deletions.
  1. +33 −10 jitb.ino
View
43 jitb.ino
@@ -67,6 +67,14 @@ int diag = 0; //set to 1 to enable diagnostic mode
const int ELKms = 500; // ELK-120 only needs a momentary contact
const int Sound1ms = 3528; // Duration of Sound #1
+void mouthtest()
+{
+ mouthServo.attach(pinMouthServo);
+ CloseMouth();
+ StartLaugh();
+ mouthServo.detach();
+}
+
void setup()
{
SetupProp();
@@ -115,36 +123,48 @@ void StartLaugh()
delay(700); //initial delay for sound to start playing
- mouthServo.writeMicroseconds(mouthopenUS);
+ OpenMouth();
delay(334);
- mouthServo.writeMicroseconds(mouthclosedUS);
+ CloseMouth();
delay(349);
- mouthServo.writeMicroseconds(mouthopenUS);
+ OpenMouth();
delay(338);
- mouthServo.writeMicroseconds(mouthclosedUS);
+ CloseMouth();
delay(262);
- mouthServo.writeMicroseconds(mouthopenUS);
+ OpenMouth();
delay(154);
- mouthServo.writeMicroseconds(mouthclosedUS);
+ CloseMouth();
delay(182);
- mouthServo.writeMicroseconds(mouthopenUS);
+ OpenMouth();
delay(466);
- mouthServo.writeMicroseconds(mouthclosedUS);
+ CloseMouth();
delay(326);
- mouthServo.writeMicroseconds(mouthopenUS);
+ OpenMouth();
delay(499);
- mouthServo.writeMicroseconds(mouthclosedUS);
+ CloseMouth();
delay(3000); //final delay to keep head up
ChangeStatus(laughingfinished);
}
+void CloseMouth()
+{
+ mouthServo.write(0);
+ //mouthServo.writeMicroseconds(mouthclosedUS);
+}
+
+void OpenMouth()
+{
+ mouthServo.write(160);
+ //mouthServo.writeMicroseconds(mouthopenUS);
+}
+
void StartProp()
{
@@ -165,12 +185,15 @@ void LowerHead()
digitalWrite(pinHeadLowerValve, HIGH);
while(isHeadDown() == false){DisplayStatus();}
digitalWrite(pinHeadLowerValve, LOW);
+ mouthServo.detach();
ChangeStatus(headlowered);
}
void RaiseHead()
{
ChangeStatus(headrising);
+ mouthServo.attach(pinMouthServo);
+ CloseMouth();
digitalWrite(pinHeadRaiseValve, HIGH);
while(isHeadUp() == false){DisplayStatus();}
ChangeStatus(headraised);

0 comments on commit c3b2f82

Please sign in to comment.