Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Stuck

$
0
0

I am trying to control a servo using an external push button on a breadboard. What am trying to do is when button is pressed servo goes to 90 degrees, when pushed again it goes back to 0 degrees. So far i have it going 90 degrees but i have been having trouble moving it back to zero.

#define button1 BIT1#define clk_freq 1000000
#define servo_freq 50
int main(void){
WDTCTL = WDTPW + WDTHOLD;


int period = clk_freq / servo_freq;


P1DIR |= servo;
P1SEL |= servo;
TACCR0 = period;
TACCR1 = 0;
TACCTL1 = OUTMOD_7;
TACTL = TASSEL_2 + MC_1;


while(1){
   if((P1IN & button1)==BIT1)  
   {
      TACCR1 = 1650;
   }
   
  //if button press again go to 0 degrees
}
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles