Added simple oscillator example

master
dennisdebel 5 years ago
parent a48cb44f23
commit 75e35b99a4

@ -0,0 +1,17 @@
/*
*
* 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.
}
Loading…
Cancel
Save