I have a problem here, can anyone explain?
the sound doesn't move directly when I turn the potentiometer, it plays the entire audio and then moves, which is a problem I don't like
I have a problem here, can anyone explain?
the sound doesn't move directly when I turn the potentiometer, it plays the entire audio and then moves, which is a problem I don't like
your playSound() function is blocking until all the samples have been sent out so you won't come back to the main loop() where you read the pot again until everything has been played.
You should look at how to write a non blocking program, articles like
and expand a bit on your state machine. Here is a small introduction to the topic: Yet another Finite State Machine introduction
May be a simple option without rewriting everything is to add an else clause to your
and check if currentThrottle has changed and act accordingly (assuming you can read the analogValue in less than 45µs — which might not be the case)
I recommend exploring non-blocking programming methods, such as using 'millis()' for timing or implementing a state machine. This will allow your program to handle multiple tasks simultaneously without delays. Perhaps adding an 'else' condition to your code to check for changes in the potentiometer's value and respond accordingly would be beneficial.
Can you give me an example and which part of the code should be improved?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.