Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

void setup() {

// put your setup code here, to run once:


Serial.begin(9600) ;
}

void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 /1023.0);
float resistance = (10.0*5.0-10.0*voltage)/(voltage);
String brightness;
if (resistance < 3.5) {
brightness = "Bright";
}
else if (resistance < 10) {
brightness = "Medium";
}
else {
brightness = "Dark";
}
Serial.print(resistance);
Serial.println(" " + brightness);
delay(500);
}

You might also like