#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
const int rs = 12, en = 11, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Data wire is conntec to the Arduino digital pin 4
#define ONE_WIRE_BUS 6
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
lcd.begin(20, 4); // set up the LCD's number of columns and rows:
lcd.setCursor(1, 0); // set the cursor to column 0, line 1
lcd.print("MAX MACHINE TOOLS");
lcd.setCursor(0, 1);
lcd.print("Load L: ");
lcd.setCursor(0, 2); // set the cursor to column 0, line 1
lcd.print("Load R: ");
lcd.setCursor(0, 3);
lcd.print("OIL Temp: ");
}
void loop() {
int sensorValue1 = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage1= sensorValue1 * (5.0 / 1023.0);
float Pressure1=voltage1 * (250.0/5.0);
lcd.setCursor(8, 1);
// print out the value you read:
lcd.print(voltage1);
lcd.setCursor(17, 1);
lcd.print("MT");
int sensorValue2 = analogRead(A1);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage2= sensorValue2 * (5.0 / 1023.0);
float Pressure2=voltage2 * (250.0/5.0);
lcd.setCursor(8, 2);
// print out the value you read:
lcd.print(Pressure2);
lcd.setCursor(17, 2);
lcd.print("MT");
delay(1000);
sensors.requestTemperatures();
lcd.setCursor(10, 3);
lcd.print(sensors.getTempCByIndex(0),2);
lcd.setCursor(17, 3);
lcd.write(223);
lcd.setCursor(18, 3);
lcd.print("C");
if (sensors.getTempCByIndex(0)>55)
{digitalWrite(7, HIGH);
}
else
{digitalWrite(7, LOW);
}
delay(1000);
Serial.println(sensors.getTempCByIndex(0));
}