Voltaje reading

Good afternoon, I’m doing a project for which I need to have a light icon and that turn it’s on as soon as one of my arduino’s analog pins detects voltage, I already have my code and it’s functional, but it takes a lot of time to detect the voltage, and it doesn’t works for my project.
I would be interested to read more ideas of code to do this, turn on a light icon as soon as an analog pin detects voltage.
I read you budies. Gretings!

you can send the data when the state changes like this:

	unsigned long currentMillis = millis();
	// Check sensor data every 250 milliseconds
	if (currentMillis - previousMillis >= 250) {
		// Check the sensor state and send data when it changes.
		currentState = digitalRead(SENSOR_PIN);
		if (currentState != previousState) {
			Cayenne.virtualWrite(VIRTUAL_CHANNEL, currentState, "digital_sensor", "d");
			previousState = currentState;
		previousMillis = currentMillis;

though you will have to adapt the code for analog pin