Skip to content

Instantly share code, notes, and snippets.

@IsmailSan
Created September 20, 2019 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IsmailSan/22784bb795fbaab197192a6d0366dace to your computer and use it in GitHub Desktop.
Save IsmailSan/22784bb795fbaab197192a6d0366dace to your computer and use it in GitHub Desktop.
#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