Expexted unqualified-id before string constant

Hi, I'm trying to make a mood lamp, this is the code:

void setup(){
  attachInterrupt(0,ISR, LOW);
  volatile int inV = 0;
  volatile int a = 0;
  volatile int val=0;
}
void loop(){
  inV=analogRead(A0);
  inV=map(inV, 0, 1023, 0, 255);
  analogWrite(13, val);
}
void ISR(){
  a++;
  if(a=3){
    a=0;
  }
  if(a=0){
    val=255;
  }
  if(a=1){
    val=inV;
  }
  if(a=2){
    return;
  }
}

and I keep getting this error:

sketch_sep14a:4: error: expected unqualified-id before string constant
sketch_sep14a:4: error: expected unqualified-id before 'void'
sketch_sep14a:4: error: expected )' before 'void' sketch_sep14a.ino: In function 'void setup()': sketch_sep14a:2: error: 'ISR' was not declared in this scope sketch_sep14a.ino: In function 'void loop()': sketch_sep14a:8: error: 'inV' was not declared in this scope sketch_sep14a:10: error: 'val' was not declared in this scope sketch_sep14a.ino: At global scope: sketch_sep14a:12: error: expected unqualified-id before string constant sketch_sep14a:12: error: expected unqualified-id before 'void' sketch_sep14a:12: error: expected )' before 'void'

can anybody tell me why? Thank you so much!

  if(a=3){

This will not do what you want. Use ==.

How many open braces are there in ISR()? How many close braces? What is the proper ratio?

Hi, I changed the = into ==, and I still get the error. Why is that?

Why is that?

Because correcting a logic error did not magically make the curly braces match.

Hi, I don't see any non-matching curly braces. Could it be something else?

I don't see any non-matching curly braces.

Look again. Your ISR function has two more } than it has {.

Sorry, I must have fixed that problem on the sketch, I didn't see it on the sketch in my computer. I think it was when I changed the code on the thread I must have mad a mistake.

How you lay your code out can make a big difference to being able to follow it.

Even if you don't intend anyone else to look at it, it is always good to provide plenty of comments. If you come back to this code in 6 or 12 months, after finishing half a dozen other projects, are you going to remember everything about your flow control and variable names chosen?

See a 1 minute edit of your code (after the suggested fising of your comparators) and then can you see what PaulS is saying?

void setup()
{
  attachInterrupt(0,ISR, LOW);
  volatile int inV = 0;
  volatile int a = 0;
  volatile int val=0;
}

void loop()
{
  inV=analogRead(A0);
  inV=map(inV, 0, 1023, 0, 255);
  analogWrite(13, val);
}

void ISR()
{
  a++;
  if(a==3)
  {
    a=0;
  }
  if(a==0)
  {
    val=255;
  }
  if(a==1)
  {
    val=inV;
  }
  if(a==2)
  {
    return;
  }
}

  }
}

arduinohabib:
when I changed the code on the thread I must have mad a mistake.

If you want help with your code you need to post your actual code, and explain what problem you're asking for help with.

Hi, really sorry. I changed the code and the error message.

I changed the code and the error message.

Do not ever do that again. If you need to repost your code, add it in a reply. Changing the initial code makes those who replied look like idiots. Personally, I don't like that, and will no longer try to help you.

Hi, I'm really sorry about that, I didn't mean to make anybody look like an idiot. Can anybody please help me?

Take a look at scopes and where variables need to be declared and what functions they are then available to. That will enable you to sort one of your problems.

The other problem is your choice of name for your interrupt function.

Thanks a lot, this works.

volatile int inV = 0;
volatile int a = 0;
volatile int val=0;
void setup(){
  attachInterrupt(0,set, LOW);
}
void loop(){
  inV=analogRead(A0);
  inV=map(inV, 0, 1023, 0, 255);
  analogWrite(13, val);
}
void set(){
  a++;
  if(a==3){
    a=0;
  }
  if(a==0){
    val=255;
  }
  if(a==1){
    val=inV;
  }
  if(a==2){
    return;
  }
}