0% found this document useful (0 votes)
29 views2 pages

NTC MF52 1OK Sensor

Uploaded by

ynsganz5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

NTC MF52 1OK Sensor

Uploaded by

ynsganz5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <Wire.

h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128


#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define NTC_PIN A2
#define NTC_PIN2 A3
#define R0 10000
#define B 3950
#define T0 298.15

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int potPin1 = A0;


const int potPin2 = A1;

unsigned long waktuTerakhir = 0;


const unsigned long interval = 0; // 1 ms

void setup() {
Serial.begin(9600);
ADCSRA |= (1 << ADPS2) | (1 << ADPS1);

if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 allocation failed");
for (;;);
}

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);

display.setCursor(23, 29);
display.print("loading......");
display.display();
delay(3000);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(59, 28);
display.print("3");
display.display();
delay(999);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(59, 28);
display.print("2");
display.display();
delay(999);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(59, 28);
display.print("1");
display.display();
delay(999);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(38, 30);
display.print("Power On !");
display.display();
delay(999);
}

void loop() {
unsigned long waktuSekarang = micros();
if (waktuSekarang - waktuTerakhir >= interval) {
waktuTerakhir = waktuSekarang;

int potValue1 = analogRead(potPin1);


int potValue2 = analogRead(potPin2);

int percentage1 = map(potValue1, 0, 1023, -20, 1);


int percentage2 = map(potValue2, 0, 1023, -20, 1);

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 10);
display.print("Chanel A:");
display.print(percentage1);
display.println("db");
display.setCursor(10, 23);
display.print("Chanel B:");
display.print(percentage2);
display.println("db");

display.setCursor(11, 36);
display.print("-");
display.setCursor(11, 49);
display.print("-");
display.setCursor(-2, 1);
display.print("|");
display.setCursor(-1, -6);
display.print("__");
display.setCursor(-2, 56);
display.print("|");
display.setCursor(-1, 57);
display.print("__");
display.setCursor(122, 1);
display.print("|");
display.setCursor(114, -6);
display.print("__");
display.setCursor(122, 56);
display.print("|");
display.setCursor(114, 57);
display.print("__");

int ntcValue = analogRead(NTC_PIN);


float Vout = (ntcValue * 5.0) / 1024.0;
float R = (Vout * 10000) / (5 - Vout);
float suhu = 1 / (1/T0 + (1/B) * log(R/R0)) - 273.15;

display.setCursor(16, 36);
display.print("Suhu A: ");
display.print(suhu);
display.println(" C");

ntcValue = analogRead(NTC_PIN2);
Vout = (ntcValue * 5.0) / 1024.0;
R = (Vout * 10000) / (5 - Vout);
suhu = 1 / (1/T0 + (1/B) * log(R/R0)) - 273.15;

display.setCursor(16, 49);
display.print("Suhu B: ");
display.print(suhu);
display.println(" C");

display.display();
delay(1);
}
}
```

You might also like