77#include "pico/stdlib.h"
88#include "pico/tone.h"
99
10- /** Example code to generate tones with Buzzer using PWM with pico-sdk.
10+ /** Example code to generate tones with Buzzer using pico-sdk.
1111 *
12- * Every sound humans encounter consists of one or more frequencies, and the
13- * way the ear interprets those sounds is called pitch.
12+ * The melody is the Christmas song "Noche de Paz" (Silent Night).
1413 *
15- * In order to produce a variety of pitches, a digital signal needs to convey
16- * the frequency of sound it is trying to reproduce. The simplest approach is
17- * to generate a 50% duty cycle pulse stream and set the frequency to the
18- * desired pitch.
19- *
20- * References:
21- * - https://www.hackster.io/106958/pwm-sound-synthesis-9596f0#overview
14+ * .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
15+ * . .
16+ * . * Song: Noche de Paz (Silent Night) .
17+ * . /.\ Instrument: Buzzer .
18+ * . /..'\ Interpreter: Raspberry Pi Pico .
19+ * . /'.'\ _ .
20+ * . /.''.'\ _[ ]_ .
21+ * . /.'.'.\ Merry Christmas! (") .
22+ * . /'.''.'.\ Feliz Navidad! `__( : )--' .
23+ * . ^^^[_]^^^ ( : ) .
24+ * . ""`-...-'"" .
25+ * . .
26+ * .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
27+ *
2228 */
2329#define BUZZER_PIN 3
2430
@@ -44,21 +50,6 @@ int main() {
4450 // Configure tone generation on BUZZER_PIN
4551 tone_init (BUZZER_PIN );
4652 while (1 ) {
47- /**
48- * .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
49- * . .
50- * . * Song: Noche de Paz (Silent Night) .
51- * . /.\ Instrument: Buzzer .
52- * . /..'\ Interpreter: Raspberry Pi Pico .
53- * . /'.'\ _ .
54- * . /.''.'\ _[ ]_ .
55- * . /.'.'.\ Merry Christmas! (") .
56- * . /'.''.'.\ Feliz Navidad! `__( : )--' .
57- * . ^^^[_]^^^ ( : ) .
58- * . ""`-...-'"" .
59- * . .
60- * .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
61- */
6253 // 1
6354 tone (BUZZER_PIN , NOTE_G4 , 1.5f );
6455 tone (BUZZER_PIN , NOTE_A4 , .5f );
0 commit comments