Skip to content

Commit ea435ff

Browse files
committed
Encoder and distance as theremin
1 parent c913c90 commit ea435ff

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Diff for: examples/Modulino_Theremin/Therem.ino

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

0 commit comments

Comments
 (0)