//Phototransistor terhubung pada GPIO 36 di board ESPectro32 | |
int photoPin = 36; | |
float potValue = 0; | |
float potVoltage = 0; | |
void setup() { | |
Serial.begin(9600); | |
delay(500); | |
} | |
void loop() { | |
//Membaca nilai phototransistor | |
potValue = analogRead(photoPin); | |
//mengkonversi nilai raw data (0 - 4095) ke tegangan (0.0V - 3.3V): | |
potVoltage = potValue * (3.3 / 4095.0); | |
Serial.print("Photo Transistor Value :"); | |
Serial.println(potValue); | |
Serial.print("Photo Transistor Voltage :"); | |
Serial.println(potVoltage); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment