Octave Key Working
This commit is contained in:
parent
a7d02d9a9b
commit
deb63bfb07
@ -10,7 +10,7 @@ void setup() {
|
|||||||
pinMode(8, OUTPUT);
|
pinMode(8, OUTPUT);
|
||||||
pinMode (7, INPUT_PULLUP);
|
pinMode (7, INPUT_PULLUP);
|
||||||
|
|
||||||
|
pinMode(5, INPUT_PULLUP);
|
||||||
Serial.begin (9600); //set up a serial connection with the computer
|
Serial.begin (9600); //set up a serial connection with the computer
|
||||||
|
|
||||||
pinMode(11, OUTPUT); //the trigger pin
|
pinMode(11, OUTPUT); //the trigger pin
|
||||||
@ -25,16 +25,19 @@ void loop() {
|
|||||||
mode = 1;
|
mode = 1;
|
||||||
}
|
}
|
||||||
float note = 0;
|
float note = 0;
|
||||||
if (digitalRead(7) == LOW){
|
if (digitalRead(7) == LOW || digitalRead(5) == LOW){
|
||||||
if (mode == 0){
|
if (mode == 0){
|
||||||
note = tune(getNote());
|
note = tune(getNote());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
note = getNote();
|
note = getNote();
|
||||||
}
|
}
|
||||||
|
if (digitalRead(5)==LOW){ //if the octave button is pressed
|
||||||
|
note *= 2;
|
||||||
|
}
|
||||||
digitalWrite(13, HIGH);
|
digitalWrite(13, HIGH);
|
||||||
Serial.print(note); //print units after the distance
|
Serial.print(note); //print frequency
|
||||||
Serial.println(" hz"); //print units after the distance
|
Serial.println(" hz"); //print units after frequency
|
||||||
tone(8, note);
|
tone(8, note);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user