Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Events triggered on a counter

Posted on 2008-10-21
3
Medium Priority
?
170 Views
Last Modified: 2012-05-05
I have a small ISR with an if statement.  I have a 360 slot trigger wheel and what im trying to do is create an if statement that will only equate true on every 8th tooth.  The idea is to make it into a 45 tooth wheel, buy only executing on every 8th.  My problem is that I'm not sure how the statement should look.

something like this maybe..........
 
if(counter % 8)
{
do some stuff
}

Open in new window

0
Comment
Question by:SeanKeys
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 2000 total points
ID: 22768982
Hello SeanKeys,

if ( counter % 8 == 0 )
{
   //do stuff
}

Regards,

sunnycoder
0
 

Author Comment

by:SeanKeys
ID: 22769290
couldn't I also do

if (!(counter % 8))



?
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 22769299
Yes ... that would work too
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question