Expected unqualified-id before numeric constant

hello,
i am trying to make a code for a scale model car with leds and buttons (i have no idea if the rest of the code works, right now i am stuck on this part).
after adding the part in void BlinkerL() {
it gave this error:

/usr/local/bin/arduino-cli compile --fqbn arduino:avr:uno --build-cache-path /tmp --output-dir /tmp/568108045/build --build-path /tmp/arduino-build-D9A8B889F901E57BA79C33613DA902C0 --library /mnt/create-efs/webide/95/f8/95f8f1688db0c02612a584e50cd0020e:jasper1234567890/libraries_v2/ServoEasing /tmp/568108045/1968

In file included from /home/builder/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h:32:0,

from /tmp/568108045/1968/1968.ino:1:

/home/builder/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino/binary.h:31:12: error: expected unqualified-id before numeric constant

#define B1 1

^

/tmp/568108045/1968/1968.ino:32:5: note: in expansion of macro 'B1'

int B1 = 0;

^~

/tmp/568108045/1968/1968.ino: In function 'void BlinkerL()':

/tmp/568108045/1968/1968.ino:57:12: error: lvalue required as left operand of assignment

if (B1 = 0) { B1 + 1;}

^

/tmp/568108045/1968/1968.ino:58:17: error: lvalue required as left operand of assignment

else if (B1 = 1) { B1 - 1;}

^

/tmp/568108045/1968/1968.ino:59:17: error: lvalue required as left operand of assignment

while (B1 = 1) { digitalWrite(BL, HIGH); delay(500); digitalWrite(BL, LOW); delay(500); }

^

/tmp/568108045/1968/1968.ino: At global scope:

/tmp/568108045/1968/1968.ino:62:1: error: expected declaration before '}' token

}

^

Error during build: exit status 1

it says it needs a declaration of somekind before '}' but in the code it doens't create that red error line, so i have no idea where or what to add. (i tried restarting the program but that didn't help)

Choose a differnt name for the B1 variable. You can modify your variable and function like this:

int blinkerState = 0; // Initialize the blinker state

void BlinkerL() {
  if (blinkerState == 0) {
    blinkerState = 1;
  } else {
    blinkerState = 0;
  }

  while (blinkerState == 1) {
    digitalWrite(BL, HIGH);
    delay(500);
    digitalWrite(BL, LOW);
    delay(500);
  }
}

It can't be both.

This is the wrong comparison. Must be

i dont understand what you mean with the top 2 can you explain more?

yeah that was a test to see if it did anything i still needed to change that back to '=='

why change B1 to BlinkerState? that is just more typing and reading.

isn't this what i wrote but just said in a different way?

and a second question, will this function (the while) be seperate from the rest of the code? that i can still perform other functions without the delay being in my way.
(i hope you understand what i am trying to say)

maybe it is smart to upload my code:

#include<Arduino.h> 

const int IF = 6;   // Interior Floor
const int IT = 9;   // Interior Top
const int BL = 7;   // Left Blinker
const int BR = 8;   // Right Blinker
const int FL = 3;   // Front Top Left
const int FR = 0;   // Front Top Right
const int FB = 4;   // Front Bottom
const int RL = 5;   // Rear Left
const int RR = 1;   // Rear Right

const int INB = A3; // Interior Button
const int LBB = A4; // Left Blinker Button
const int RBB = A6; // Right Blinker Button
const int FTB = A0; // Front Top Button
const int FBB = A1; // Front Bottom Button
const int REB = A2; // Rear Button


const int buttonPins[] = { INB, LBB, RBB, FTB, FBB, REB };
const int pinCountB = 6;

int previousButtonState[] = { LOW, LOW, LOW, LOW, LOW, LOW };
const int PreviousCount = 6; 
int presentButtonState[] ={ LOW, LOW, LOW, LOW, LOW, LOW } ;
const int PresentCount = 6;

int b;
int Pv;
int Ps;
int B1 = 0;
int B2 = 0;

void setup() {
  for(int b = 0; b < pinCountB; b++)
  for(int Pv = 0; Pv < PreviousCount; Pv++)
  for(int Ps = 0; Ps < PresentCount; Ps++)
pinMode(buttonPins[b], INPUT_PULLUP);
pinMode(IF, OUTPUT);
pinMode(IT, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(BR, OUTPUT);
pinMode(FL, OUTPUT);
pinMode(FR, OUTPUT);
pinMode(FB, OUTPUT);
pinMode(RL, OUTPUT);
pinMode(RR, OUTPUT);

}

void Interior() {
  if (IF == 0) { IF + 250; analogWrite(IF, 250);  /* analogWrite(IT, 250); */  }
  else if (IF == 250) {IF - 250; analogWrite(IF, 0); /* analogWrite(IT, 0); */  }
}
void BlinkerL() {
  if (B1 = 0) { B1 + 1;}
  else if (B1 = 1) { B1 - 1;}
    while (B1 = 1) { digitalWrite(BL, HIGH); delay(500); digitalWrite(BL, LOW); delay(500); }

  }
}
void BlinkerR() {
}
void FrontT() {
}
void FrontB() {
} 
void Rear() {  
}

void loop() {
 for(int b = 0; b < pinCountB; b++)
 for(int Pv = 0; Pv < PreviousCount; Pv++)
 for(int Ps = 0; Ps < PresentCount; Ps++)
previousButtonState[Pv]  = presentButtonState[Ps];      /* Storing the last state of the button in the present state of button */

presentButtonState[Ps] = digitalRead(buttonPins[b]);
delay(15);
  if(previousButtonState[Pv] == HIGH && presentButtonState[Pv] == LOW);
{
 if (previousButtonState[0] = HIGH) {Interior;}
 if (previousButtonState[1] = HIGH) {BlinkerL;}
  if (previousButtonState[2] = HIGH) {BlinkerR}
   if (previousButtonState[3] = HIGH) {FrontT;}
    if (previousButtonState[4] = HIGH) {FrontB;}
     if (previousButtonState[5] = HIGH) {Rear;}
 
} }

okay, thanks i did not know that the system itself uses B1. i will change it to BlinkerStateL to indicate the state of the left blinker

Good.

Better, however slightly, would be

leftBlinkerState

as it is clearer sooner that it isn't rightBlinkerState

a7

your right

thank you! this solved my issue.