Controlling sound waves with potentiometer

Описание к видео Controlling sound waves with potentiometer

How It Works:
Key Features in This Code
1. Amplitude Adjustment:
Controlled by the potentiometer on AMPLITUDE_POT_PIN to increase or decrease wave height.
2. Wave Length Adjustment:
Controlled by the potentiometer on LENGTH_POT_PIN to stretch or compress the wave horizontally.
3. Sensitivity Adjustment (Optional):
An additional potentiometer connected to SENSITIVITY_POT_PIN adjusts:
Threshold: Ignoring noise below a certain level.
Scaling: Making waves more or less responsive to the sensor.
4. Fixed Sensitivity Option:
If you don’t connect a potentiometer to SENSITIVITY_POT_PIN, you can set sensitivityThreshold and sensitivityFactor manually.

1. • Turn the amplitude potentiometer: You should see the wave get taller or shorter.
2. • Turn the length potentiometer: The peaks and troughs should spread out (longer wavelength) or move closer together (shorter wavelength).

Frequency Mapping Adjustment:
frequencyFactor = map(lengthAdjust, 0, 4095, 50, 500) / 100.0;
• 50: This is the minimum frequency factor (spread-out waves).
• 500: This is the maximum frequency factor (closer waves).
• Dividing by 100.0 ensures that the frequencyFactor is scaled appropriately.
Increasing the upper bound (e.g., 500) will bring the wave cycles closer together.
How to Fine-Tune:
• Closer Cycles: Increase the upper limit of the map() function (e.g., 50, 1000).
• More Spread-Out Cycles: Decrease the lower limit (e.g., 20, 500).

Expected Behavior:
1. When Turning the Length Potentiometer:
Turning it one way will make the waves spread out (longer wavelength).
Turning it the other way will make the waves cycle closer together (shorter wavelength).
2. Dynamic Adjustment:
The wave should move smoothly as you adjust the potentiometer, dynamically adjusting the distance between cycles.
3. Example Fine-Tuning for Closer Waves:
4. If you want really tight cycles, you can use the following range:
frequencyFactor = map(lengthAdjust, 0, 4095, 100, 1000) / 100.0;
This will allow very short wavelengths when the potentiometer is fully turned.
Wiring
Components:
1. Sound Sensor:
OUT - SOUND_SENSOR_PIN (GPIO 1).
VCC - 3.3V.
GND - GND.
2. Amplitude Potentiometer:
Middle pin - AMPLITUDE_POT_PIN (GPIO 2).
One side - 3.3V.
Other side - GND.
3. Wave Length Potentiometer:
Middle pin - LENGTH_POT_PIN (GPIO 3).
One side - 3.3V.
Other side - GND.
4. Sensitivity Potentiometer (Optional):
Middle pin - SENSITIVITY_POT_PIN (GPIO 4).
One side - 3.3V.
Other side - GND.

Code:
https://github.com/ukkokalevala/WaveA...

Комментарии

Информация по комментариям в разработке