Created
September 20, 2019 09:45
-
-
Save IsmailSan/22784bb795fbaab197192a6d0366dace 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
#include <Wire.h> | |
#include "SSD1306.h" | |
SSD1306 display(0x3c, 21, 22); | |
int photoPin = 36; | |
float potValue = 0; | |
float potVoltage = 0; | |
void setup() { | |
display.init(); | |
} | |
void loop() { | |
display.clear(); | |
//Membaca Nilai Phototransistor | |
potValue = analogRead(photoPin); | |
// mengkonversi nilai raw data (0 - 4095) ke tegangan (0.0V - 3.3V): | |
potVoltage = potValue * (3.3 / 4095.0); | |
display.drawString(0, 0, "Pot Value : " + String(potValue)); | |
display.drawString(0, 20, "Pot Voltage : " + String(potVoltage)); | |
display.display(); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment