Skip to content

Commit bcbc800

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

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/Modulino_Theremin/Therem.ino

Lines changed: 33 additions & 0 deletions
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 value = 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+
value = encoder.get();
26+
27+
if (value < 0 || value > 11) {
28+
value = 0;
29+
encoder.set(0);
30+
}
31+
32+
buzzer.tone(note[value] + pitch, 300);
33+
}

0 commit comments

Comments
 (0)