expected ';' before numeric constant - Can't figure out my syntax error.

Hi everyone.

I've been banging my head against a wall with this one for a few evenings now, reading tutorials, forum posts,, working my way through examples, but I just haven't been able to figure out where my mistake is. I am very much the beginner with Arduino, so I'm sure my code mistake is painfully obvious and my code is terrible, so I would very much appreciate some help.

I'm getting "expected ';' before numeric constant" on line 28 (or line 18 if I delete line 28). I've never had problems with if statements before, so why this has me stumped I don't know.

Thanks again for any assistance.

Interrupts.ino (742 Bytes)

const int mom1 = 2;
const int mom2 = 3;
int countA = 0;
int countApre = 0;
int countB = 0;
int countBpre = 0;

void setup() {
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(mom1), button1, RISING);
attachInterrupt(digitalPinToInterrupt(mom2), button2, RISING);
}

void loop() {
}

void button1() {
  if (countApre<99) countA++1;
  else if (countApre = 99) countA == 0;
  Serial.print("A: ");
  Serial.print(count1);
  Serial.print("B: ");
  Serial.print(count2);
  countApre == countA;
}

void button2() {
  if (countBpre<99) countB++1;
  else if (countBpre = 99) countB == 0;
  Serial.print("A: ");
  Serial.print(count1);
  Serial.print("B: ");
  Serial.print(count2);
  countBpre == countB;
}
 countApre == countA;

Oops

countA++1;

probably should be

countA++;

if (countApre = 99) Oops

Oh, and don't do serial I/O in interrupt context.

Wow, what a warm welcome!
A sarcastic pointing out of other (apparent) errors with no explanation of why they are so, or how to correct them, or even a nudge in the right direction, another apparent correction, again with no explanation, and you didn't even help with my question!

Well, I assumed if you couldn't even be bothered to post your code, you'd be happy to do a bit of foraging for answers.

You're welcome.

void button1() {
  if (countApre < 99) countA++;
  else if (countApre == 99) countA = 0;
  Serial.print("A: ");
  Serial.print(count1);
  Serial.print("B: ");
  Serial.print(count2);
  countApre = countA;
}

Similarly for 'B'..... :wink:

skywatch:

void button1() {

if (countApre < 99) countA++;
  else if (countApre == 99) countA = 0;
  Serial.print("A: ");
  Serial.print(count1);
  Serial.print("B: ");
  Serial.print(count2);
  countApre = countA;
}




Similarly for 'B'..... ;)

...apart from the "don't do serial I/O in interrupt context" bit.

I'm sorry, as you can see, I'm a new member, I had thought that the attachment feature would embed my code in the post, and I was actually typing out an apology with the code tags when I discovered the 5 minute lockout between posts for new members and you had already replied with my code embedded. I'm not asking anyone to do my code for me, quite the opposite, I want to understand, but frankly you're just rude, and should really re-read your above post and think twice about posting like that, not a very nice way to foster a community.

You probably need to read this - it is posted in bold at the top of this section of the forum.

Again, you're welcome.

I deleted your response - it was either that, or a ban.

If, as you had said, you had studied forum posts, you would have got from here to here and eventually to your fellow Aussie's page here, where, very near the top, for those with short attention-spans, a TL;DR; with the following excellent advice

When writing an Interrupt Service Routine (ISR):

Keep it short
Don't use delay ()
Don't do serial prints
Make variables shared with the main code volatile
Variables shared with main code may need to be protected by "critical sections" (see below)
Don't try to turn interrupts off or on

(my emphasis).

GregRobinson:
Wow, what a warm welcome!

GregRobinson:
Wow, what a warm welcome!

Sarcasm.

A sarcastic pointing out...

Criticizing another for being sarcastic. Oh the irony.

Except that "oops" is used correctly so there is no way to know if @AWOL was sarcastic or terse. It's interesting you decided it was the former. Then continued clutching to that assumption despite @AWOL's helping you. So you see @AWOL solely as sarcastic but he could actually be helpful and terse.

GregRobinson:
...but frankly you're just rude...

The dictionary disagrees.