#define SENSOR_TOP_PIN 34 // เซนเซอร์ด้านบน
#define SENSOR_BOTTOM_PIN 35 // เซนเซอร์ด้านล่าง
void setup() {
Serial.begin(115200);
pinMode(SENSOR_TOP_PIN, INPUT);
pinMode(SENSOR_BOTTOM_PIN, INPUT);
}
void loop() {
int topValue = analogRead(SENSOR_TOP_PIN); // อ่านค่า ADC ด้านบน
int bottomValue = analogRead(SENSOR_BOTTOM_PIN); // อ่านค่า ADC ด้านล่าง
float topDistance = map(topValue, 0, 4095, 0, 100); // ระยะด้านบน (ตัวอย่าง)
float bottomDistance = map(bottomValue, 0, 4095, 0, 100); // ระยะด้านล่าง
float thickness = topDistance - bottomDistance; // คำนวณความหนา
Serial.println("Thickness: " + String(thickness) + " mm");
delay(100);
}