Pages: [1]   Go Down
Author Topic: Error: expected primary expression before 'a' .(in an if statement)Please help.  (Read 440 times)
0 Members and 1 Guest are viewing this topic.
Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Arduino_Random_Movement.ino: In function 'void pulsewait':
Arduino_Random_Movement:49: error: expected primary-expression
before 'a'
smiley-confuse

...And here's the code (Only the problem section)
Code:
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:
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!)
Logged

I'm on PHYRE!

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4258
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is actually in the line before
Code:
  word a; - 1;
Logged

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

Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, what should I do, because when it tells me about the error the line I mentioned is highlighted...? smiley-confuse
Logged

I'm on PHYRE!

Offline Offline
Edison Member
*
Karma: 48
Posts: 1632
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pete

Logged

Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
HIGH ;13;
is part of pulsing a PING ultrasonic sensor,
Code:
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.
Logged

I'm on PHYRE!

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26312
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the examples of C you've worked through, have you ever seen constructs like the ones you've written there?
Logged

"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.

Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nope.

(P.S. I don't even know what you're talking about)
Logged

I'm on PHYRE!

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26312
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I'm on PHYRE!

Pages: [1]   Go Up
Jump to: