Hi,
I wrote if statement
if ((nutrition_lvl < alert_nutrition_lvl) && (SMS6 == false)) {
A6l.sendSMS(number1, "xxx");
SMS6 == true;
}
but I get "expected primary-expression before ')' token" error. I can't find my mistake, with previous if statements I don't get any errors. Can someone help me with that? Thanks.
I'd guess the problem is not in that bit of code unless it's actually related to the sendSMS() not the if.
If you show the complete sketch and the actual error listing which includes the line number we might have a better chance of working out what's going on.
Steve
Please post more of your program, preferably all of it. The actual problem is likely to be before the lines that you posted but does not cause an error until these lines are encountered.
SMS6 == true
It's not your problem, but that statement is pointless.=
Thank you all for reply. Here is my code:
#include <A6lib.h>
//Alerts
#define alert_water_lvl
#define alert_nutrition_lvl
//A6 GSM
#define D0 10 //PWR Pin
#define D5 11 //TX A6
#define D6 12 //RX A6
A6lib A6l(D6, D5);
String number1 = "";
String number2 = "";
bool SMS5 = false;
bool SMS6 = false;
//Water and nutrition level
int water_lvl = 0;
int pin_water = 10;
int nutrition_lvl = 0;
int pin_nutrition = 11;
void gather_water_lvl() {
water_lvl = 0;
water_lvl = analogRead(pin_water);
water_lvl = constrain(water_lvl, 200, 900);
water_lvl = map(water_lvl, 200, 900, 99, 0);
Serial.print(water_lvl);
Serial.println("l");
}
void gather_nutrition_lvl() {
nutrition_lvl = 0;
nutrition_lvl = analogRead(pin_nutrition);
nutrition_lvl = constrain(nutrition_lvl, 200, 900);
nutrition_lvl = map(nutrition_lvl, 200, 900, 99, 0);
Serial.print(nutrition_lvl);
Serial.println("l");
}
void setup() {
Serial.begin(115200);
A6l.powerCycle(D0);
A6l.blockUntilReady(9600);
delay(1000);
}
void loop() {
if ((water_lvl < alert_water_lvl) && (SMS5 == false)) {
A6l.sendSMS(number1, "xxx");
SMS5 = true;
}
if ((nutrition_lvl < alert_nutrition_lvl) && (SMS6 == false)) {
A6l.sendSMS(number1, "xxx");
SMS6 = true;
}
}
gfvalvo
February 23, 2018, 1:17pm
6
You didn't define actual values for these macros:
#define alert_water_lvl
#define alert_nutrition_lvl
This would be much better:
const int alert_water_lvl = PUT A NUMBER HERE;
const int alert_nutrition_lvl = PUT A NUMBER HERE;
Now do you see why it's a good idea to show your complete program in the first place?
gfvalvo:
You didn't define actual values for these macros:
#define alert_water_lvl
#define alert_nutrition_lvl
This would be much better:
const int alert_water_lvl = PUT A NUMBER HERE;
const int alert_nutrition_lvl = PUT A NUMBER HERE;
Now do you see why it's a good idea to show your complete program in the first place?
Thank you! I was looking at this code for a long time and didn't see that mistake...
Have a nice day!