#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
#define pinPM 34
void setup() {
Serial.begin(9600);
Serial.println("Sistem Monetoring Potensio Meter");
Serial.println("Kelompok 6");
delay(1000);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
}
void loop() {
float valuePot = analogRead(pinPM);
float x = valuePot / 4095;
float voltase = x * 3;
int kondisi1 = 0;
int kondisi2 = 30;
int kondisi3 = 254;
if(valuePot == 4095) {
Serial.print(voltase);
display.setTextSize(1);
display.setCursor(0,0);
display.print(voltase);
display.display();
display.clearDisplay();
}
if(valuePot >=2482 && valuePot <=4094) {
Serial.print(voltase);
display.setTextSize(1);
display.setCursor(0,0);
display.print(voltase);
display.display();
display.clearDisplay();
}
if(valuePot >= 0 && valuePot <=2481) {
Serial.print(voltase);
display.setTextSize(1);
display.setCursor(0,0);
display.print(voltase);
display.display();
display.clearDisplay();
}
delay(1000);
}