boolean expression getting "expected primary expression error"

With this area of my code, I'm getting "expected primary expression before 'm' on line 20

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if (boolean n=true && boolean m=true)


the full area of code is:
if (sensors.getTempFByIndex(0) <212)
{
  boolean n=true;
  digitalWrite (10, HIGH);
} else {
  boolean n=false;
  digitalWrite (10, LOW);
}
if (sensorValue >=0 && sensorValue <=25)
{
  boolean m=true;
} else {
  boolean m=false;
}

if (boolean n=true && boolean m=true)
{
  boolean p=true;
}
while (boolean p=true)
{
  digitalWrite 10, HIGH);
Last edited on
= is assignment
== is comparison
comparing a boolean against true or false is superfluous.

I guess that you've received «error: `foo' was not declared in this scope» messages and so prefixed every use of your variable with its type. That's not how it works.
read about scope http://www.cplusplus.com/doc/tutorial/namespaces/
variables exist in the block they are declared and names are meaningless.

1
2
3
4
5
6
7
8
9
10
11
12
13
bool n = sensors.getTemmpFByIndex(0) < 212;
if(n)
   digitalWrite(10, HIGH);
else
   digitalWrite(10, LOW);

bool m = sensorValue<=0 and sensorValue<=25;
bool p = m and n;
while (p)
{
  digitalWrite(10, HIGH);
  //¿does `p' change here?
}
this is assuming that you are using c++
Topic archived. No new replies allowed.