Skip to content

Pi pico control PWM with arduino IDE? #184

Answered by Andy2No
bill-rubasse asked this question in Q&A
Discussion options

You must be logged in to vote

I made a start on making a PWM tone generator, which is the same problem but intended more for music. The idea is to just watch the microseconds timer, and decide if it's time to flip the state of the output, yet.

The downside is that if an interrupt happens, the state will stay as it is for a little longer than it should, but will flip the next time the code inside the loop is called.

I originally intended to add code to make a siren, so there are some variables in this that don't do anything, yet. Everything is global, and not even in structures, because I wanted to keep it as cycle efficient as possible.

Since this doesn't wait, you could rename the loop() as something else, e.g. pwm_u…

Replies: 10 comments 5 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
0 replies
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 bill-rubasse
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Hyper-ZX
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
2 replies
@earlephilhower
Comment options

@Laserjones
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
6 participants