Adding A Gain Potentiometer.
Prompt
The signal is very low on the display. I have added a Potentiometer on ADC1 which is on GPIO PIN 27. Can you please regenerate the entire program with sound on ADC0 and gain on ADC1. sound = ADC(Pin(26)) gain = ADC(Pin(27))
ChatGPT-
Certainly! To adjust the signal's amplitude on the display based on the gain from a potentiometer connected to ADC1 (GPIO PIN 27), you can modify the program as follows. This updated script will use the value from the potentiometer to scale the audio signal from the microphone, making the waveform larger or smaller on the OLED display according to the potentiometer's position.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
In this script, the gain control (potentiometer) reading is used to adjust the amplitude of the sound signal before plotting it. The gain_value
is read from ADC1 and is used to scale the audio signal from the microphone connected to ADC0. The line adjusted_val = min(((val * gain_value) >> 16), 65535)
scales the microphone input based on the potentiometer's position, and the bit shift >> 16
is used to keep the value within the 16-bit range of the ADC's output.
This method should help make the displayed signal more responsive to the potentiometer's adjustments, allowing you to visually enhance or reduce the waveform amplitude on the OLED display.