Skip to content

Play melody page mistake? #6229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grjonjon opened this issue Apr 27, 2017 · 4 comments
Closed

Play melody page mistake? #6229

grjonjon opened this issue Apr 27, 2017 · 4 comments
Assignees
Labels
Component: Documentation Related to Arduino's documentation content Type: Bug

Comments

@grjonjon
Copy link

grjonjon commented Apr 27, 2017

In "Play melody" page there are two code examples for producing tones on a passive piezo buzzer.
However, in the 1st example the user is instructed to use a "PWM pin" of the Arduino for producing the tone, which is pretty restricting. By going through the code I see that the tone is produced in software by turning that pin HIGH and LOW at predetermined time intervals; this can be done with a "non-PWM" pin, and to my opinion, more correctly so. After all, the used pin isn't used as a PWM out.
Correct me if I'm wrong.

@cmaglie cmaglie added the Component: Documentation Related to Arduino's documentation content label Apr 28, 2017
@Rotzbua
Copy link
Contributor

Rotzbua commented Apr 28, 2017

Can you provide the link?

If I remember correctly, the pins have different timings to change the state and the PWM was the fastest pin..

@facchinm
Copy link
Member

facchinm commented May 2, 2017

The link should be https://www.arduino.cc/en/Tutorial/PlayMelody .
In fact the first example doesn't need a PWM pin, while the second code (which uses analogWrite ) does. I believe that the pin was chosen that way to switch easily between the two examples; however the comments on the first example should be slightly changed.

@tigoe
Copy link
Member

tigoe commented Oct 1, 2019

Related to this, there appears to be an issue with tone() on the SAMD boards. When you play a tone of frequency <1, it freezes up. In the playMelody() example, for example, on a nano 33 Iot, it plays the first five notes of "shave and a haircut", then stops. If you change the sixth note, which is currently 0, to 1, then it plays the whole tune, "shave and a haircut, two bits".

I haven't tried to replicate this on the other architectures recently, but I know that it worked on the Uno as of version 1.8.9.

@per1234
Copy link
Collaborator

per1234 commented Sep 29, 2020

I seems that PlayMelody tutorial was removed completely from arduino.cc sometime after 2020-07-20. Since nothing remains to fix, I'll go ahead and close this.

The bug reported by @tigoe was fixed by arduino/ArduinoCore-samd#520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Related to Arduino's documentation content Type: Bug
Projects
None yet
Development

No branches or pull requests

7 participants