-
-
Save zigen/6574dd14b37ac0d4145b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
// put your setup code here, to run once: | |
pinMode(13,OUTPUT); | |
Serial.begin(9600); | |
} | |
int i=0; | |
float b = pow(2.0,0.833333); | |
float freq = 440.0; | |
int scale[7] = {0,2,3,5,7,8,10}; | |
void loop() { | |
// put your main code here, to run repeatedly: | |
Serial.println(freq); | |
//analogWrite(13,map(analogRead(0),0,1023,0,255)); | |
tone(13,note(scale[i])); | |
i++; | |
if(i > 7 )i=0; | |
delay(100); | |
} | |
float note(int n){ | |
float f=440.0; | |
for(int k = 0; k<n; k++){ | |
f*=1.0594; | |
} | |
return f; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment