ScreenDisplayTemperatureTest.ino (564B)
1 #include <Wire.h> 2 #include <LiquidCrystal_I2C.h> 3 LiquidCrystal_I2C lcd(0x27, 16, 2); 4 5 void setup() { 6 lcd.init(); 7 lcd.backlight(); 8 Serial.begin(9600); 9 } 10 11 void loop() { 12 int sensorValue = analogRead(A0); 13 float voltage = sensorValue * (5.0 / 1023.0); 14 int leftSideOfRatio = 5 / voltage; 15 String HalfwayThroughCircutVolts = String(voltage) + " V"; 16 String RatioBetweenCenterAndStartVolts = String(leftSideOfRatio) + ":1"; 17 lcd.setCursor(5, 0); 18 lcd.print(HalfwayThroughCircutVolts); 19 lcd.setCursor(6, 1); 20 lcd.print(RatioBetweenCenterAndStartVolts); 21 }