Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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