Created
September 11, 2019 06:04
-
-
Save IsmailSan/582e4fc6acd1178144ab4cb3f71266fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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