const byte LIGHT_PIN = A9;
const float REFERENCE_V = 3.3;
void setup() { Serial.begin(9600); }
void loop() {
int light = analogRead(LIGHT_PIN);
float volts = light * (REFERENCE_V / 1023.0);
Serial.print("light:"); Serial.print(light);
Serial.print(",volts:"); Serial.println(volts, 3);
delay(100);
}
Shared from Little Bird Electronics curriculum.