Files
yoradio/exsamples/plugins/analogvolume.ino
2022-06-28 14:53:55 +03:00

17 lines
588 B
C++

/**************************************************************
An example of volume control using an analog resistor.
This file must be in the root directory of the sketch.
**************************************************************/
const uint8_t volume_pin = 34;
void ctrls_on_loop() {
static uint32_t prevVolPinMillis;
uint16_t volPinVal = map(analogRead(volume_pin), 0, 4095, 0, 254);
if((abs(volPinVal-config.store.volume)>2) && (millis()-prevVolPinMillis>300)){ /* simple debounce */
player.setVol(volPinVal, false);
prevVolPinMillis=millis();
}
}