Jump to content
43oh

Interruption with button counter


Recommended Posts

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;      
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...