/* PitchChanger Uses a potentiometer to control the pitch of a speaker. The circuit: * Potentiometer with middle pin connected to analog pin 0 (with other pins connected to ground and +5V. * The speaker connected from digital pin 8 to ground. Created 5 May 2010 By Jacob Simpson Based on an idea for an 'Annoy-a-Tron' customised for Arduino. */ // Constants won't change. They're used here to set pin numbers: const int potPin = 0; // Potentiometer connected to Analog pin 0. // Variables will change: int val = 0; // Variable for reading the potentiometer. void setup() { } void loop() { tone(8, val); // Play tone on pin 8 at the frequency set by the potentiometer }
void loop(){ val = map(analogRead(potPin), 0, 1023, 100, 1000); tone(8, val);}