Skip to content

Commit 9c415ac

Browse files
authored
Update README.md
1 parent 6122e73 commit 9c415ac

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
11
# RTTL_arduino
22
RTTTL format parser for Arduino
3+
4+
Author: Milda Zizyte
5+
6+
Developed for Lab 4 (Clocks, timers, and watchdogs) in CSCI 1600: Embedded and real-time software at Brown University (more information [here](https://cs.brown.edu/courses/info/csci1600/).)
7+
8+
## Overview
9+
10+
This repository includes code to parse an RTTTL string into buffers of note frequencies and durations. It can then be used in conjunction with e.g. the [Tone library](https://github.com/daniel-centore/arduino-tone-library).
11+
12+
Examples of RTTTL-formatted songs can be found [here](http://www.cellringtones.com/)
13+
14+
## Usage
15+
16+
You can download the files as-is and run `rtttl_parser_test` on an Arduino with the Serial Monitor open. This code runs some unit tests for the library, and you should see that the tests pass.
17+
18+
To use these files for your own Arduino project, copy `rtttl_parser` and `pitches.h` into your project folder. Then, you can parse an RTTTL string using the `rtttl_to_buffers` function.
19+
20+
Example usage:
21+
22+
```
23+
#include "pitches.h"
24+
25+
...
26+
27+
const String song = "spooky:d=4,o=6,b=127:8c,f,8a,f,8c,b5,2g,8f,e,8g,e,8e5,a5,2f,8c,f,8a,f,8c,b5,2g,8f,e,8c,d,8e,1f,8c,8d,8e,8f,1p,8d,8e,8f_,8g,1p,8d,8e,8f_,8g,p,8d,8e,8f_,8g,p,c,8e,1f";
28+
int note_frequencies[100];
29+
int note_durations[100];
30+
int song_len;
31+
32+
song_len = rtttl_to_buffers(song, note_frequencies, note_durations);
33+
if (song_len == -1) {
34+
Serial.println("ERROR PARSING SONG!");
35+
while(true);
36+
}
37+
// note_frequencies and note_durations now contains the frequencies and durations for the song, in sequence
38+
```
39+

0 commit comments

Comments
 (0)