Go Down

Topic: Error: expected primary expression before 'a' .(in an if statement)Please help. (Read 564 times) previous topic - next topic

Phyremaster

I am using the Arduino Uno in a science project, and I can't figure out the first error I get by clicking the verify button. When I click the verify button I get a string of errors, and I can't solve the small ones until I get the first one done.

Here's the error (Only the first one):
Code: [Select]

Arduino_Random_Movement.ino: In function 'void pulsewait':
Arduino_Random_Movement:49: error: expected primary-expression
before 'a'

:~

...And here's the code (Only the problem section)
Code: [Select]

void pulsewait() {
  long duration, inches;
  HIGH ;13;
  delayMicroseconds(2);
  LOW ;13;
  duration = pulseIn(12, HIGH);
  inches = microsecondsToInches(duration);
  long microsecondsToInches(long microseconds);
  if (inches < 8)
  {
    halt();
    HIGH ;3;
    delay ;1500;
    LOW ;3;
    word a = 0;
  }
  delay ;1;
  word a; - 1;
  if (word a > 0)
  {
    pulsewait();
    }
  }


The problem is on this line:
Code: [Select]

if (word a > 0)


If you can help, please do! Thanks in advance!
(And if it's something "obvious", sorry, I'm a preteen noob!)
I'm on PHYRE!

UKHeliBob

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Phyremaster

Well, what should I do, because when it tells me about the error the line I mentioned is highlighted...? :~
I'm on PHYRE!

el_supremo

What is this?
Code: [Select]
  HIGH ;13;
and this?
Code: [Select]
    delay ;1500;
You are also calling pulsewait recursively which is going to cause you problems.

Pete


Phyremaster

Code: [Select]

HIGH ;13;

is part of pulsing a PING ultrasonic sensor,
Code: [Select]

delay ;1500;

is part of moving away from an obstacle, and pulsewait repeating is part of going forward for a random amount of time, constantly checking the PING sensor.
I'm on PHYRE!

AWOL

In the examples of C you've worked through, have you ever seen constructs like the ones you've written there?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Phyremaster

I'm on PHYRE!

AWOL

Quote
I don't even know what you're talking about

The IDE includes a good number of C/C++ examples, useful for learning and giving hints.
You need to work through a few.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Phyremaster


Quote
I don't even know what you're talking about

The IDE includes a good number of C/C++ examples, useful for learning and giving hints.
You need to work through a few.


OOOOOOOOHHHHHHHHHH................ Those examples............................Nope.
I'm on PHYRE!

Go Up