I've got a simple if statement inside my code that I keep getting the following error about,
bmp_lcd:87: error: expected primary-expression before '=' token
if (millis() - sampleClock >= sampleInt) {
readBmp();
storePress();
sampleClock = millis();
I can't figure it out because it looks like it should be right. I thought maybe that I couldn't have an expression in the if statement so I tried it with the subtraction outside of the statement and stored a variable and got the same result. Any ideas?
I've posted the whole piece of code below, in case it's something else that's going on.
#include <Wire.h>
#include <BMP085.h>
#include <LiquidCrystal.h>
#define sampleInt = 5000
#define baroInt = 1800000
BMP085 bmp;
LiquidCrystal lcd(4,5,6,7,8,9);
byte mode = 0;
int sampleClock = 0;
long baroClock = 0L;
float temp, feet, press, oldPress = 0;
boolean baroDirection, tUnits = true;
void setup() {
lcd.begin(16, 2);
bmp.begin();
lcd.clear();
oldPress = bmp.readPressure() * .000296;
}
void readBmp() {
temp = bmp.readTemperature();
feet = bmp.readAltitude() * 3.28;
press = bmp.readPressure() * .000296;
}
void displayPressure(boolean dir) {
lcd.clear();
lcd.setCursor(0,0);
if (dir == true) {
lcd.print("Falling");
}
else {
lcd.print("Rising");
}
lcd.print(" Pressure");
lcd.setCursor(0,1);
lcd.print("of ");
lcd.print(press, 2);
lcd.print(" inches");
}
void displayTemp(boolean format) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Current Temp =");
lcd.setCursor(0,1);
if (format == true) {
lcd.print(temp, 2);
}
else {
lcd.print(((temp * 1.8) + 32), 2);
}
lcd.print(" degrees ");
if (format == true) {
lcd.print ("C");
}
else {
lcd.print ("F");
}
}
void displayElevation() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Elevation above");
lcd.setCursor(0,1);
lcd.print("MSL = ");
lcd.print(feet, 0);
lcd.print(" ft.");
}
void storePress() {
if (millis() - baroClock >= baroInt) {
if (press < oldPress) {
baroDirection = true;
}
else {
baroDirection = false;
}
oldPress = press;
}
}
void loop() {
if (millis() - sampleClock >= sampleInt) {
readBmp();
storePress();
sampleClock = millis();
}
switch (mode) {
case 0:
displayTemp(tUnits);
break;
case 1:
displayPressure(baroDirection);
break;
case 2:
displayElevation();
break;
default:
mode = 0;
}
}