Oscillator controlled by a potentiometer

Hi everyone,

Can someone help me?!
I need to help a friend finishing her installation today, but I need your help.
I want to code a simple oscillator controlled by a potentiometer, connected to a speaker.

The goal is to emulate some CYMATICS in a speaker, with a container of water.
I have some experience with cymatics, and I know it's possible and simple.
But I don't how to code an oscillator, and I need your help.

If is it possible to ask for a scheme how to code and how to assemble it, it would be really helpful because she needs to finish this today.

Thank you all for this great community*

I moved your topic to an appropriate forum category @joaomiro.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

But first we need your help in telling us about this project.
First off, what sort of Arduino are you hoping to use?
Then what frequency range do you want?
What waveform do you want, I am assuming a sin wave?
Finally what sort of power do you need to supply to the object you want to vibrate?

It is unlikely that you will be able to get the amplifier you need today, so is it worth the effort?

I made it.

#include <Encoder.h>

const int encoderDT = 2;
const int encoderCLK = 3;
const int speakerPin = 9;

Encoder myEncoder(encoderDT, encoderCLK);
int lastEncoderPos = 0;
int frequency = 0;

void setup() {
pinMode(speakerPin, OUTPUT);
}

void loop() {
int encoderPos = myEncoder.read();

if (encoderPos != lastEncoderPos) {
// Adjust the frequency based on the encoder position change
frequency += (encoderPos - lastEncoderPos) * 10;
frequency = constrain(frequency, 50, 5000); // Limit the frequency range
}

tone(speakerPin, frequency);
lastEncoderPos = encoderPos;
}

I think this is what you are looking for:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.