Skip to content

Commit

Permalink
Encoder and distance as theremin
Browse files Browse the repository at this point in the history
  • Loading branch information
giulio93 committed Jun 30, 2024
1 parent c913c90 commit cda3d12
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/Modulino_Theremin/Modulino_Theremin.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "Modulino.h"

ModulinoBuzzer buzzer;
ModulinoDistance distance;
ModulinoKnob encoder;


void setup() {

Modulino.begin();
encoder.begin();
distance.begin();
buzzer.begin();
}

int pitch = 0;
int noteIndex = 0;

//Notes from C to B with #
int note[] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};

void loop() {
pitch = distance.get();
noteIndex = encoder.get();

noteIndex = noteIndex % 11;
if (noteIndex < 0){
noteIndex = 0;
}

buzzer.tone(note[noteIndex] + pitch, 1000);
}

0 comments on commit cda3d12

Please sign in to comment.