This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int ledPin = 13; | |
| //led for visualization (use 13 for built-in led) | |
| int speakerPin = 11; | |
| //speaker connected to one of the PWM ports | |
| #define c 261 | |
| #define d 294 | |
| #define e 329 | |
| #define f 349 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int speakerPin = 5; | |
| int length = 26; | |
| char notes[] = "eeeeeeegcde fffffeeeeddedg"; | |
| int beats[] = { 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}; | |
| int tempo = 300; | |
| void playTone(int tone, int duration) { | |
| for (long i = 0; i < duration * 1000L; i += tone * 2) { | |
| digitalWrite(speakerPin, HIGH); | |
| delayMicroseconds(tone); |