cheverecamachidoche 13 Posted April 14, 2012 Share Posted April 14, 2012 Hello guys im making a program that count the number of button pushes with a interruption, every time that the button is pushed a servomotor get a position of 4 positions availables, the problem is when the servomotor get the last position and then I push the button one more time the servomotor is in the same last position so I would like that when I push the button the servomotor start again in the first position, I tried with return and break but it doesnt work, please any advice? here the interruption: #pragma vector=PORT2_VECTOR __interrupt void Port2_ISR(void) { if(!(PxIFG & GDO0_PIN)); if(PxIFG & GDO0_PIN); { conta++; } if (conta==1) { Firstposition(); } if (conta ==2) { Secondposition(); } if (conta ==3) { Thirdposition(); } if (conta ==4) { Quarterposition(); } else; // I tried break and return like this: //break; //return; PxIFG &= ~GDO0_PIN; } Quote Link to post Share on other sites
oPossum 1,083 Posted April 14, 2012 Share Posted April 14, 2012 switch(conta) { case 1: // default: // All other case values conta = 1; // Reset count Firstposition(); break; case 2: Secondposition(); break; case 3: Thirdposition(); break; case 4: Quarterposition(); break; } cheverecamachidoche 1 Quote Link to post Share on other sites
cheverecamachidoche 13 Posted April 15, 2012 Author Share Posted April 15, 2012 Thanks Opossum now is working Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.