Hi guys, another noobie question.
Why am i getting this compile error? Picture attached to illustrate. no1.
It only does it when i add the if/else lines.
What am i doing wrong, i tried adding separate voids but that didn't work.
Without the if else it works fine pic 2.
/*
MultiTempSensor
*/
//Include's
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h> // Library for LCD
#include <Wire.h> // Library for I2C communication
//Constants
#define SENSOR_PIN 5
#define READ_TIMER 10000 //10 seconds
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4); // Change to (0x27,16,2) for 16x2 LCD.
LiquidCrystal_I2C lcd1 = LiquidCrystal_I2C(0x26, 20, 4); // Change to (0x27,16,2) for 16x2 LCD.
//
OneWire oneWire(SENSOR_PIN);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//Sensor Adresses
DeviceAddress Sensor1 = { 0x28, 0x31, 0xAF, 0x78, 0x32, 0x19, 0x01, 0xBD };
DeviceAddress Sensor2 = { 0x28, 0xF9, 0xD8, 0x76, 0x32, 0x19, 0x01, 0xAA };
//DeviceAddress Sensor3 = { 0x28, 0xFF, 0x38, 0xB3, 0x60, 0x16, 0x03, 0xEA };
//DeviceAddress Sensor4 = { 0x28, 0xFF, 0xA4, 0xBE, 0x60, 0x16, 0x03, 0xE1 };
//DeviceAddress Sensor5 = { 0x28, 0xFF, 0xFE, 0x13, 0x61, 0x16, 0x03, 0x56 };
//DeviceAddress Sensor6 = { 0x28, 0xFF, 0x89, 0xBA, 0x60, 0x16, 0x03, 0xFB };
//DeviceAddress Sensor7 = { 0x28, 0xFF, 0xFA, 0xBC, 0x60, 0x16, 0x03, 0xD1 };
//DeviceAddress Sensor8 = { 0x28, 0xFF, 0x57, 0xB1, 0x60, 0x16, 0x03, 0x93 };
int amountOfSensors = 2;
const int oilswitch = 12; // the number of the oilswitch input pin
const int oilfault = 13; // the number of the output pin to the relay
//variable to check amount of sensors on bus once in a while
int counterCheckBus = 0;
int oilState = 0; // variable for reading the oil switch status
void setup()
{
pinMode(oilswitch, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
// Initiate the LCD:
lcd.init();
lcd.backlight();
lcd1.init();
lcd1.backlight();
Serial.begin(9600);
sensors.begin();
byte customChar[] = { //Custom char fuel droplet
B00100,
B00100,
B01110,
B11111,
B11111,
B11111,
B11111,
B01110
};
byte customChar1[] = { //custom char oil temp
B00110,
B00100,
B00110,
B00100,
B00100,
B01110,
B11111,
B01110
};
byte customChar2[] = { //custom char deg c
B10000,
B00011,
B00100,
B01000,
B01000,
B01000,
B00100,
B00011
};
byte customChar3[] = { //custom char snowflake
B00100,
B10001,
B01010,
B10101,
B10101,
B01010,
B10001,
B00100
};
byte customChar4[] = { //custom char fuel pump rh
B10100,
B10010,
B10011,
B11001,
B10101,
B10111,
B10000,
B11111
};
byte customChar5[] = { //custom char fuel pump lh
B01111,
B01000,
B01000,
B01000,
B01111,
B01101,
B01111,
B11111
};
byte customChar6[] = { //custom char battery symbol
B01010,
B11111,
B10001,
B11111,
B10001,
B11111,
B10001,
B11111
};
lcd.createChar(0, customChar);
lcd.createChar(1, customChar1);
lcd.createChar(2, customChar2);
lcd.createChar(3, customChar3);
lcd.createChar(4, customChar4);
lcd.createChar(5, customChar5);
lcd.createChar(6, customChar6);
// Startup screen, will show on power up
lcd.setCursor(0,1);
lcd.print("START UP PLEASE WAIT");
delay(3000);
lcd.setCursor(0,1);
lcd.print(" ");
delay(2000);
lcd.setCursor(0,1);
lcd.print(" V-TWIN TURBO ");
delay(2000);
lcd.setCursor(0,1);
lcd.print(" ");
delay(2000);
lcd.setCursor(0,1);
lcd.print(" 16 HP ");
delay(2000);
lcd.setCursor(0,1);
lcd.print(" ");
delay(3000);
// start serial port to show results
Serial.begin(9600);
//display_Running_Sketch();
//printProgramName();
lcd.setCursor(1,0);
lcd.print("BRIGG'S & STRATTON");
lcd.setCursor(4,2);
lcd.print("V14.06.2020");
delay(3000);
lcd.clear();
delay(1000);
lcd.setCursor(1,1);
lcd.print("Searching for ");
lcd.setCursor(18,1);
lcd.print(amountOfSensors);
lcd.setCursor(2,3);
lcd.println("sensors");
delay(5000);
lcd.clear();
delay(1000);
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Sensor1, 10);
sensors.setResolution(Sensor2, 10);
//sensors.setResolution(Sensor3, 10);
//sensors.setResolution(Sensor4, 10);
//sensors.setResolution(Sensor5, 10);
//sensors.setResolution(Sensor6, 10);
//sensors.setResolution(Sensor7, 10);
//sensors.setResolution(Sensor8, 10);
getSensorsOnBus();
Serial.println("System initialized");
}
void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue *(100 / 1023.0);
lcd.setCursor(15,0);
lcd.print(voltage,1);
lcd.setCursor(18,0);
lcd.print(" % ");
int sensorValue1 = analogRead(A1);
float voltage1 = sensorValue1 *(24.0 / 1023.0);
lcd.setCursor(15,3);
lcd.print(voltage1,1);
lcd.setCursor(19,3);
lcd.print("V ");
//Oil pressure status, input from pin 2
oilState = digitalRead(oilswitch);
//Use this one for fuel symbol
//lcd.setCursor(13, 0);
//lcd.write(byte(5)); //fuel symbol
//lcd.setCursor(14, 0);
//lcd.write(byte(4)); //fuel symbol
//Use this one for droplet
lcd.setCursor(13, 0);
lcd.write(byte(0)); //fuel symbol
lcd.setCursor(0, 0);
lcd.write(byte(1)); //temp symbol
lcd.setCursor(7, 0);
lcd.write(byte(2) ); //oc symbol
lcd.setCursor(13,3);
lcd.write(byte(6));//Battery symbol
if (oilState == HIGH) {
//lcd.setCursor(17, 0);
//lcd.print("LOW");
lcd1.setCursor(2,3);
lcd1.print("LOW OIL PRESSURE");
//delay(1000);
digitalWrite(LED_BUILTIN, LOW);
} else {
//lcd.setCursor(17, 0);
//lcd.print("OK ");
lcd1.setCursor(2,3);
lcd1.print(" ");
digitalWrite(LED_BUILTIN, HIGH);
}
counterCheckBus++;
delay(READ_TIMER);
Serial.println();
if (counterCheckBus == 360)
{
getSensorsOnBus();
counterCheckBus = 0;
}
sensors.requestTemperatures();
Serial.print("Sensor 1: ");
printTemperature(Sensor1);
Serial.println();
// Print 'Input text' on the first line of the LCD:
//lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
//lcd.write(byte(1));
//lcd.print("O/T "); // print the oil temp
//lcd.setCursor(2,0);
//lcd.print();
//lcd.setCursor(8, 0); //Set the cursor on the third column and the second row (counting starts at 0!).
//lcd.print("c");
Serial.print("Sensor 2: ");
printTemperature(Sensor2);
Serial.println();
//Serial.print("Sensor 3: ");
//printTemperature(Sensor3);
//Serial.println();
//Serial.print("Sensor 4: ");
//printTemperature(Sensor4);
//Serial.println();
//Serial.print("Sensor 5: ");
//printTemperature(Sensor5);
//Serial.println();
//Serial.print("Sensor 6: ");
//printTemperature(Sensor6);
//Serial.println();
//Serial.print("Sensor 7: ");
//printTemperature(Sensor7);
//Serial.println();
//Serial.print("Sensor 8: ");
//printTemperature(Sensor8);
//Serial.println();
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Sensor error!");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
float oil = tempC;
lcd.setCursor(2,0);
lcd.print(oil,1);
//delay(1000);
//float water = tempC;
//lcd.setCursor(8,1);
//lcd.print(water,1);
{
} if (tempC <= 30.00)
{
lcd1.setCursor(4,2);
lcd1.print("OIL TEMP LOW");
}
else
lcd1.setCursor(4,2);
lcd1.print(" ");
}
}
void printProgramName() {
String path = __FILE__;
int slash = path.lastIndexOf('\\');
String programName = path.substring(slash + 1);
int dot = programName.lastIndexOf('.');
programName = programName.substring(0, dot);
Serial.print("\nProgram version: ");
Serial.println(programName);
}
void getSensorsOnBus() {
Serial.print("Number of sensors found on bus: ");
Serial.println(sensors.getDeviceCount());
}