From da4c398d7f2d61b0c228c625af72c7425d0a994b Mon Sep 17 00:00:00 2001 From: Damlanur Date: Fri, 18 Oct 2019 16:51:25 +0200 Subject: [PATCH] - --- sketches/damla-sketch/tonestudy/tonestudy.ino | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 sketches/damla-sketch/tonestudy/tonestudy.ino diff --git a/sketches/damla-sketch/tonestudy/tonestudy.ino b/sketches/damla-sketch/tonestudy/tonestudy.ino new file mode 100644 index 0000000..b79f40b --- /dev/null +++ b/sketches/damla-sketch/tonestudy/tonestudy.ino @@ -0,0 +1,35 @@ +//controlling pitch of tones with pin 1 + +void setup() { + // put your setup code here, to run once: + int i = 0; //to stop playback after it reaches a certain amount of loops + int x = analogRead(1); //get pin 1's value + x = map(x, 0, 1023, 1, 50); //map the value (which is between 0 and 1023 to between 1 and 50 + + Serial.begin(9600); //serial for debugging + Serial.println("hello"); + + Serial.println("counter is now"); + Serial.println(i); + + while (i < 100){ //it will stop playing after counter reaches to 100 + tone(11, random(100,200)*x, 200); //play a random tone frequency of which is determined by multiplying a number between 100 and 200 with the x value + delay(50); + tone(11, random(100,400)*x, 200); + delay(50); + tone(11, random(100,600)*x, 200); + delay(50); + i = i + 1; //count up + x = analogRead(1); //get knob value again + x = map(x, 0, 1023, 1, 50); + + Serial.println("counter is now"); + Serial.println(i); + } +} + +void loop() { + + + +}