play_frequency(freq,dur,vol) on the 3pi

Can’t get the code to work for the play_frequency() command. Am working with a 3pi. Here’s the code:

#include <pololu/3pi.h>

int main()

The problem is that the 1000 Hz frequency won’t stop playing, even after 1000 ms duration has ended.

I checked the cautionary rule: freq x duration / 1000 must be less than 65535. In this case, the duration (in ms) is well below the max value.

Adding a short delay (500 ms) after the play_frequency() command has no effect; though a long delay (1000 ms) does make the command work.

I am not interested in playing a musical note, just want to play a short beep to notify me of an event.

Any thoughts?


You should never let main() return in an AVR program. Just add a while(1); as the last line to make sure that you will not break out of that function - otherwise you get undefined behavior.