Oooooo. What about having the knob change the tone of the speaker? No prob. Same idea as the previous sketch. Just map the knob values to tone frequencies.
The Circuit Playground speaker is really only usable over a range of about 100Hz to 10000Hz, which leads us to the following code.
/////////////////////////////////////////////////////////////////////////////// // Circuit Playground Analog In - Speaker Fun ? // // Author: Carter Nelson // MIT License (https://opensource.org/licenses/MIT) #include <Adafruit_CircuitPlayground.h> uint16_t value; uint16_t freq; /////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(9600); CircuitPlayground.begin(); } /////////////////////////////////////////////////////////////////////////////// void loop() { value = analogRead(10); freq = map(value, 0, 1023, 100, 10000); CircuitPlayground.playTone(freq, 100, false); }
Load that code up and run it. Spin the knob. Make some weird outer space theremin like music sounds. Hopefully the dogs don't start howling.
Page last edited February 08, 2017
Text editor powered by tinymce.