You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
392 B
Arduino

/*
*
* Simple (PWM) Oscillator!
*
*/
#define SPEAKER_PIN 11
void setup() {
// set pin 11 as output
pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
// tone needs output pin and frequency. Here the frequency is determined by reading from analog input 2 (0-1023), or the top potentiometer
tone(SPEAKER_PIN, analogRead(A2));
delay(100); // a delay adds stability to the tone.
}