ソースを参照

Changed Mode Port, and added a velocity button

master
コミット
29e79f00f6
1個のファイルの変更14行の追加3行の削除
  1. +14
    -3
      Theremin/Theremin.ino

+ 14
- 3
Theremin/Theremin.ino ファイルの表示

@@ -5,25 +5,36 @@
*/
int mode;
void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode (13, OUTPUT);
pinMode(8, OUTPUT);
pinMode (7, INPUT_PULLUP);

Serial.begin (9600); //set up a serial connection with the computer

pinMode(11, OUTPUT); //the trigger pin
pinMode(12, INPUT); //echo pin
if (digitalRead(0) ==HIGH){
if (digitalRead(6) ==HIGH){
mode = 0;
mode = 1;
}
}

void loop() {

if (digitalRead(7) == LOW){
if (mode == 0){
digitalWrite(13, HIGH);
tone(8, getNote());
}
}
else{
noTone(8);
}
}


float getNote()
{
float echoTime;
@@ -35,7 +46,7 @@ float getNote()
echoTime = pulseIn(12, HIGH);
calculatedDistance = echoTime / 8;
calculatedDistance += 110;
if (calculatedDistance > 1760){ //
if (calculatedDistance > 1760){ //git

calculatedDistance = 1760;
}


読み込み中…
キャンセル
保存