#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int analogReadings[] = {50,120,30,500,87,45,77,80,94,100,
201,120,144,400,15,141,17,118,200,220};
// Constants for voltage calculation
const float VOLTAGE_REFERENCE = 5.0;
const int ADC_RESOLUTION = 1023;
void setup() {
allwaysDisplay();
}
void loop() {
long data = 0;
for (int i = 0; i <20; i++) {
allwaysDisplay();
// Calculate voltage
float voltage = (float)analogReadings[i] * VOLTAGE_REFERENCE / ADC_RESOLUTION;
// Calculate temperature in Celsius and Fahrenheit (example formula)
float tempCelsius = (voltage - 0.5) * 100.0;// استخدام عامل التحويل 100.0 لتحويل الجهد إلى درجات مئوية.
float tempeFahrenheit = (tempCelsius * 9.0 / 5.0) + 32.0;//سيحول درجة الحرارة بالسيلسيوس إلى درجة الحرارة بفهرنهايت.
// Display voltage and temperature on LCD
lcd.setCursor(0, 1);
lcd.print(voltage, 2); //مع رقمين عشريين LCDيتم طباعة قيمة الجهد على شاشة
lcd.setCursor(0, 2);
lcd.print(tempeFahrenheit, 2); // Display temperature in Fahrenheit with 2 decimal place
lcd.setCursor(0, 3);
lcd.print(tempCelsius, 2); // Display temperature in Celsius with 2 decimal place
delay(5000); // Update display every 5 seconds
lcd.clear(); // Clear the LCD for the next reading
}
}
void allwaysDisplay(){
lcd.begin(20, 4);
lcd.print("__Yassin Ameen__");
lcd.setCursor(8, 1);
lcd.print("V");
lcd.setCursor(8, 2);
lcd.print("F");
lcd.print(char(223));// ASCIIيطبع درجة الـ(°) باستخدام قيمة 223 في جدول .
lcd.setCursor(8, 3);
lcd.print("C");
lcd.print(char(223));// ASCIIيطبع درجة الـ(°) باستخدام قيمة 223 في جدول .
}