Animatronic Neck

Program Download:

Main C & Hex File
Animatronic_Neck.c
Animatronic_Neck.hex

The Software
           Since we are using the same servo signal for both eyes now, we save a bit of hardship and don't have to change any of the software from the previous Animatronic Mouth tutorial. We can actually use the exact same code and control the new animatronic face!

           Since the code is the same, I'll just make note of the differences in what signals from the PIC are now controlling what servos. The comments below in bold show you the changes.

PWM Control - Interrupt Routine

------------« Begin Code »------------
...
....
else if(PIR1bits.TMR1IF == 1)
{ //If Timer1 interrupts, do your thing...
count++; //Increment Timer1 Interrupt Counter
     switch(count){ //Choose which servo to modify
          case 1: PORTD = 0x01;
               WriteTimer1( servo0 ); //Right Eyebrow
               break;
          case 2: PORTD = 0x02;
               WriteTimer1( servo1 ); //Left Eyebrow
               break;
          case 3: PORTD = 0x04;
               WriteTimer1( servo2 ); //Eyes Left/Right
               break;
          case 4: PORTD = 0x08;
               WriteTimer1( servo3 ); //Eyes Up/Down
               break;
          case 5: PORTD = 0x10;
               WriteTimer1( servo4 ); //Neck Rotate Left/Right
               break;
          case 6: PORTD = 0x20;
               WriteTimer1( servo5 ); //Neck Tilt Up/Down
               break;
          case 7: PORTD = 0x40;
               WriteTimer1( servo6 ); //Mouth
               break;
          case 8: PORTD = 0x00;
               WriteTimer1( 0 );
               break;
          }
          PIR1bits.TMR1IF = 0; //Clear Timer1 flag
}
....
...
------------« End Code »------------

           It is really a blessing to be able to use the exact same software because now we can spend more time programming in animatronic movements using the move() function and making our animatron do cool things! Let's take a look at the data section to see what this animatron is up to now.



;