Hello,
check this small sketch:
// CONSTANT DEFINITION
// you may need to change these constants to your hardware
const byte Analog[] {A0, A1};
const byte Output_ {2};
const byte Button_ {A2};
void setup() {
Serial.begin(9600);
pinMode (Output_, OUTPUT);
pinMode( Button_,INPUT_PULLUP);
}
void loop () {
unsigned long currentTime = millis();
static unsigned long LEDmillis;
if (currentTime - LEDmillis >= (unsigned long) map(analogRead(Analog[digitalRead(Output_)]), 0, 1023, 50, 500) && !digitalRead(Button_)) {
digitalWrite(Output_, !digitalRead(Output_));
LEDmillis = currentTime;
}
}