mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Made changes to TonePitchFollower example for clarity, suggestions by user Michael Flynn
This commit is contained in:
parent
ca181e3318
commit
4b7bc3b584
@ -9,8 +9,13 @@
|
|||||||
* 4.7K resistor on analog 0 to ground
|
* 4.7K resistor on analog 0 to ground
|
||||||
|
|
||||||
created 21 Jan 2010
|
created 21 Jan 2010
|
||||||
|
<<<<<<< HEAD:build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino
|
||||||
modified 9 Apr 2012
|
modified 9 Apr 2012
|
||||||
by Tom Igoe
|
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.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -29,10 +34,11 @@ void loop() {
|
|||||||
int sensorReading = analogRead(A0);
|
int sensorReading = analogRead(A0);
|
||||||
// print the sensor reading so you know its range
|
// print the sensor reading so you know its range
|
||||||
Serial.println(sensorReading);
|
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
|
// change the minimum and maximum input numbers below
|
||||||
// depending on the range your sensor's giving:
|
// 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:
|
// play the pitch:
|
||||||
tone(9, thisPitch, 10);
|
tone(9, thisPitch, 10);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user