// Definición de pines y parámetros
const int photoResistorPin = A0; // Pin analógico donde está conectado el fotorresistor
float VRef = 5.0; // Voltaje de referencia (ajustable si es necesario)
const int ADCResolution = 1023; // Resolución del ADC (10 bits: 0-1023)
void setup() {
Serial.begin(9600); // Inicializa comunicación serie
pinMode(photoResistorPin, INPUT); // Configura el pin del fotorresistor como entrada
}
void loop() {
// Lee el valor analógico del fotorresistor
int rawValue = analogRead(photoResistorPin);
// Convierte el valor analógico a voltaje
float voltage = (rawValue / (float)ADCResolution) * VRef;
// Imprime los resultados en el monitor serie
Serial.print("Valor ADC: ");
Serial.print(rawValue);
Serial.print(" | Voltaje: ");
Serial.print(voltage);
Serial.println(" V");
// Delay para evitar saturar el monitor serie
delay(500);
}