Skip to content

Commit 8441dd9

Browse files
authored
Theremin example (#8)
* Encoder and distance as theremin
1 parent 711d286 commit 8441dd9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "Modulino.h"
2+
3+
ModulinoBuzzer buzzer;
4+
ModulinoDistance distance;
5+
ModulinoKnob encoder;
6+
7+
8+
void setup() {
9+
10+
Modulino.begin();
11+
encoder.begin();
12+
distance.begin();
13+
buzzer.begin();
14+
}
15+
16+
int pitch = 0;
17+
int noteIndex = 0;
18+
19+
//Notes from C to B with #
20+
int note[] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
21+
22+
void loop() {
23+
pitch = distance.get();
24+
noteIndex = encoder.get();
25+
26+
noteIndex = noteIndex % 11;
27+
if (noteIndex < 0){
28+
noteIndex = 0;
29+
}
30+
31+
buzzer.tone(note[noteIndex] + pitch, 1000);
32+
}

0 commit comments

Comments
 (0)