Skip to content

Commit 4b7bc3b

Browse files
author
Tom Igoe
committed
Made changes to TonePitchFollower example for clarity, suggestions by user Michael Flynn
1 parent ca181e3 commit 4b7bc3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
* 4.7K resistor on analog 0 to ground
1010
1111
created 21 Jan 2010
12+
<<<<<<< HEAD:build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino
1213
modified 9 Apr 2012
1314
by Tom Igoe
15+
=======
16+
modified 31 May 2012
17+
by Tom Igoe, with suggestion from Michael Flynn
18+
>>>>>>> Made changes to TonePitchFollower example for clarity, suggestions by user Michael Flynn:build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.ino
1419
1520
This example code is in the public domain.
1621
@@ -29,10 +34,11 @@ void loop() {
2934
int sensorReading = analogRead(A0);
3035
// print the sensor reading so you know its range
3136
Serial.println(sensorReading);
32-
// map the pitch to the range of the analog input.
37+
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
38+
// to the output pitch range (120 - 1500Hz)
3339
// change the minimum and maximum input numbers below
3440
// depending on the range your sensor's giving:
35-
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
41+
int thisPitch = map(sensorReading, 400, 1000, 120, 1500);
3642

3743
// play the pitch:
3844
tone(9, thisPitch, 10);

0 commit comments

Comments
 (0)