diff --git a/modules/simple-osc/simple-osc.ino b/modules/simple-osc/simple-osc.ino new file mode 100644 index 0000000..b32bcea --- /dev/null +++ b/modules/simple-osc/simple-osc.ino @@ -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. +}