From 4b7bc3b584e8978db450113d8d995ddeef529c45 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Thu, 31 May 2012 18:23:59 -0400 Subject: [PATCH] Made changes to TonePitchFollower example for clarity, suggestions by user Michael Flynn --- .../02.Digital/tonePitchFollower/tonePitchFollower.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino index 2bdf0df26..f92607a3c 100644 --- a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino +++ b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino @@ -9,8 +9,13 @@ * 4.7K resistor on analog 0 to ground created 21 Jan 2010 +<<<<<<< HEAD:build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino modified 9 Apr 2012 by Tom Igoe +======= + modified 31 May 2012 + by Tom Igoe, with suggestion from Michael Flynn +>>>>>>> Made changes to TonePitchFollower example for clarity, suggestions by user Michael Flynn:build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.ino This example code is in the public domain. @@ -29,10 +34,11 @@ void loop() { int sensorReading = analogRead(A0); // print the sensor reading so you know its range Serial.println(sensorReading); - // map the pitch to the range of the analog input. + // map the analog input range (in this case, 400 - 1000 from the photoresistor) + // to the output pitch range (120 - 1500Hz) // change the minimum and maximum input numbers below // depending on the range your sensor's giving: - int thisPitch = map(sensorReading, 400, 1000, 100, 1000); + int thisPitch = map(sensorReading, 400, 1000, 120, 1500); // play the pitch: tone(9, thisPitch, 10);