/*#include <Arduino.h>
#include "main.h"
#define NTC_PIN A0
#define UART_SERIAL Serial
void setup() {
// ตั้งค่า UART
UART_SERIAL.begin(9600);
// ตั้งค่าขา NTC
pinMode(NTC_PIN, INPUT);
}
void loop() {
// อ่านค่า ADC จาก NTC
uint16_t adcValue = analogRead(NTC_PIN);
// แปลงค่า ADC เป็นอุณหภูมิ (Celsius)
float temperatureCelsius = ntcThermistor(adcValue);
// แปลงค่าอุณหภูมิ (Celsius) เป็นอุณหภูมิ (Fahrenheit)
float temperatureFahrenheit = (temperatureCelsius * 9.0 / 5.0) + 32.0;
// แสดงค่าอุณหภูมิ (Fahrenheit) ผ่าน UART
UART_SERIAL.print("อุณหภูมิ: ");
UART_SERIAL.print(temperatureFahrenheit);
UART_SERIAL.println(" F");
// รอ 1 วินาที
delay(1000);
}
// ฟังก์ชันสำหรับแปลงค่า ADC เป็นอุณหภูมิ (Celsius)
float ntcThermistor(uint16_t adcValue) {
// ค่าคงที่สำหรับ NTC Thermistor
const float R1 = 10000.0;
const float beta = 3950.0;
const float T0 = 25.0;
// คำนวณค่าความต้านทาน NTC
float Rntc = (R1 * (float)(1023 - adcValue)) / (float)adcValue;
// คำนวณค่าอุณหภูมิ (Celsius)
float temperatureCelsius = 1.0 / (1.0 / T0 + (beta / Rntc) * log(Rntc / R1));
return temperatureCelsius;
}*/