Skip to content

Interrupt too slow to count 21Hz? #1629

Closed Answered by Andy2No
pcfreak1201 asked this question in Q&A
Discussion options

You must be logged in to vote

@pcfreak1201 It looks like you're calling analogWrite() too often. Each time you do that it may start the PWM cycle again; I'm not sure. Either way, there's no benefit to updating more often than once in every several cycles of its output. Have you checked it's producing what you think it is from the PWM pin?

If you're aiming to produce a 20Hz PWM signal, you probably shouldn't try updating the PWM value more than a few times a second. If you want to time how many counts there were in a certain time interval, you should probably set that quite a bit slower than the update period, otherwise you won't be getting much precision in the answer - the count will always be very small, so difficul…

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@earlephilhower
Comment options

Comment options

You must be logged in to vote
1 reply
@earlephilhower
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pcfreak1201
Comment options

You must be logged in to vote
1 reply
@pcfreak1201
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants