-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRtttl2Code.ino
More file actions
56 lines (46 loc) · 1.54 KB
/
Rtttl2Code.ino
File metadata and controls
56 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <anyrtttl.h>
#include <binrtttl.h>
#include <pitches.h>
// Define the BUZZER_PIN for current board
#if defined(ESP32)
#define BUZZER_PIN 25 // Using GPIO25 (pin labeled D25)
#elif defined(ESP8266)
#define BUZZER_PIN 2 // Using GPIO2 (pin labeled D4)
#else // base arduino models
#define BUZZER_PIN 9
#endif
//project's constants
const char * tetris = "tetris:d=4,o=5,b=160:e6,8b,8c6,8d6,16e6,16d6,8c6,8b,a,8a,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,2a,8p,d6,8f6,a6,8g6,8f6,e6,8e6,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,a";
//*******************************************************************************************************************
// The following replacement functions prints the function call & parameters to the serial port.
//*******************************************************************************************************************
void serialTone(uint8_t pin, unsigned int frequency, unsigned long duration) {
Serial.print("tone(");
Serial.print(pin);
Serial.print(",");
Serial.print(frequency);
Serial.print(",");
Serial.print(duration);
Serial.println(");");
}
void serialNoTone(uint8_t pin) {
Serial.print("noTone(");
Serial.print(pin);
Serial.println(");");
}
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(115200);
Serial.println();
//Use custom functions
anyrtttl::setToneFunction(&serialTone);
anyrtttl::setNoToneFunction(&serialNoTone);
}
void loop() {
anyrtttl::blocking::play(BUZZER_PIN, tetris);
while(true)
{
// prevent watchdog to reset the board
delay(1000);
}
}