Expected ( before token ;

i am getting an error in the pinmode verify area that i dont know why im getting

 

here is my code

 

 

 

#define rightdc 5;
#define leftdc 4;
#define middleir A0;
#define leftir A1;
#define rightir A2;

int danger = 1000;

void setup()
{
 pinMode(rightdc, OUTPUT);
 pinMode(leftdc, OUTPUT);
}

void loop()
{
if (analogRead(middleir) < danger)
digitalWrite (right && leftdc, HIGH;

else if (analogRead(rightir) < danger)
digitalWrite (leftdc, HIGH);

else if (analogRead(leftir) < danger)
digitalWrite(rightdc, HIGH);

else if(analogRead(leftir && middleir) < danger)
digitalWrite(leftdc && rightdc, HIGH);

else if(analogRead(rightir && middleir) < danger)
digitalWrite(leftdc && rightdc, HIGH);

else if (analogRead(leftir && middleir && rightir) < danger)
digitalWrite (rightdc && leftdc, HIGH);

else if (analogRead(leftir && rightir) < danger)
digitalWrite(rightdc && leftdc, HIGH);

else (digitalWrite(leftdc, HIGH)
}

I think this is correct.

#define RIGHTDC 5
#define LEFTDC 4
#define MIDDLEIR A0
#define LEFTIR A1
#define RIGHTIR A2
#define DANGER 1000

void setup() {
  pinMode(RIGHTDC, OUTPUT);
  pinMode(LEFTDC, OUTPUT);
}

void loop() {
  if (analogRead(MIDDLEIR) < DANGER) {
    digitalWrite(RIGHTDC, HIGH);
    digitalWrite(LEFTDC, HIGH);
  } else if (analogRead(RIGHTIR) < DANGER) {
    digitalWrite (LEFTDC, HIGH);
  } else if (analogRead(LEFTIR) < DANGER) {
    digitalWrite(RIGHTDC, HIGH);
  } else if ((analogRead(LEFTIR) < DANGER) &&
             (analogRead(MIDDLEIR) < DANGER)) {
    digitalWrite(LEFTDC, HIGH);
    digitalWrite(RIGHTDC, HIGH);
  } else if ((analogRead(RIGHTIR) < DANGER) &&
             (analogRead(MIDDLEIR) < DANGER)) {
    digitalWrite(LEFTDC, HIGH);
    digitalWrite(RIGHTDC, HIGH);
  } else if ((analogRead(LEFTIR) < DANGER) &&
             (analogRead(MIDDLEIR) < DANGER) &&
             (analogRead(RIGHTIR) < DANGER)) {
    digitalWrite(RIGHTDC, HIGH);
    digitalWrite(LEFTDC, HIGH);
  } else if ((analogRead(LEFTIR) < DANGER) &&
             (analogRead(RIGHTIR) < DANGER)) {
    digitalWrite(RIGHTDC, HIGH);
    digitalWrite(LEFTDC, HIGH);
  } else {
    digitalWrite(LEFTDC, HIGH);
  }
}

Get to know your error messages

/Here is what you are asking for. I have removed all the errors in your code.
The semicolons on your defines are giving you the error in question. 
Once you remove those there are three other errors which are 
probably just typing mistakes on your part.
You left dc off the end of right in your if statement and in the last line 
your  brace before the digitalwrite needs removing and a 
semicolon placed at the end./

#define rightdc 5
#define leftdc 4
#define middleir A0
#define leftir A1
#define rightir A2

int danger = 1000;

void setup()
{
 pinMode(rightdc, OUTPUT);
 pinMode(leftdc, OUTPUT);
}

void loop()
{
if (analogRead(middleir) < danger)
digitalWrite (rightdc && leftdc, HIGH);

else if (analogRead(rightir) < danger)
digitalWrite (leftdc, HIGH);

else if (analogRead(leftir) < danger)
digitalWrite(rightdc, HIGH);

else if(analogRead(leftir && middleir) < danger)
digitalWrite(leftdc && rightdc, HIGH);

else if(analogRead(rightir && middleir) < danger)
digitalWrite(leftdc && rightdc, HIGH);

else if (analogRead(leftir && middleir && rightir) < danger)
digitalWrite (rightdc && leftdc, HIGH);

else if (analogRead(leftir && rightir) < danger)
digitalWrite(rightdc && leftdc, HIGH);

else digitalWrite(leftdc, HIGH);
}

/At first error messages may be intimidating but they really are a big help 
and worth getting to understand. It makes for fast debugging when you can 
follow them/

Ok…

Merser did a good job, this code is now syntactically correct.

But the following statement:

digitalWrite (rightdc && leftdc, HIGH); 

does not do set both the rigthtdc and leftdc pins to high. In this case it only sets pin 5, because rightdc && leftdc means 5 && 4 which is 5. If you had other pins, let’s say 3 and 4, you would have set pin 7, and nothing would happen to your motors, but you might have triggered something else. Think of how many hours you might have spent debbuging this :slight_smile:

The same goes for analogRead(leftir && middleir && rightir). This is worse than trying to write to multiple pins because it makes no sense even if you could specify multiple pins the way you are. What do you mean by reading 3 pins at once? Do you want the average? The sum? The minimum? 

Then you go into all these if statements, half of which are not even reachable because their conditions would always be false (if I interpreted your “analogRead(leftir && rightir) < danger” correctly as “(analogRead(leftir) < danger) && (analogRead(rightir) < danger)” ).

Even if the logic had been correct the robot wouldn’t work very well.

Two ifs in one

I could not help but notice that everyone is talking about bit shifting, but I can’t seem to find an example of what your line should be. I think you are looking for:

variableOne = analogRead(some pin)
variableTwo = analogRead(some other pin)
if (variableOne < threshold && variableTwo < threshold) // if varOne is smaller AND varTwo is smaller as well, then…
{
  do something
}

if you want to do an “or” it would be: 
variableOne = analogRead(some pin)
variableTwo = analogRead(some other pin)
if (variableOne < threshold || variableTwo < threshold)  // if varOne is smaller  OR varTwo is smaller, then…
{
  do something
} 

Heh thanks, I didn’t look

Heh thanks, I didn’t look any further than fixing the code that was causing errors in the compiler. Whether the code will still do what he expects now wasn’t my concern. Too many lessons at once can overwhelm.

Learn from past mistakes

LoL, I just had the same problem again and I looked up the problem and got my own post, fixed now

At least with a forum post over just asking in the shout box

left you with a trail to follow. :slight_smile:

Good to know you were able to help yourself.