I have successfully copied and pasted a particular sketch (code) from the project page at least a dozen times over the last 5 years. Then I got a new computer with Windows 11 and upgraded the IDE (2.3.6). Now when I verify the compilation I get multiple faults detected. Often (EXPECTED UNQUALIFIED-id BEFORE NUMERIC CONSTANT). I went back to my previous IDE but the problem persists. It appears that I may have lost something (syntax?) during the transitions. You can probably tell that I am not very software literate, but any simple suggestions would be greatly appreciated.
Welcome to the forum
As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum
Start by posting your full sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
It is also helpful to post full error messages in code tags as it makes it easier to scroll through them and copy them for examination
To post the error message, click the "COPY ERROR MESSAGES" button in the IDE, paste the copied messages in a reply here, select all of it and click the < CODE > icon above the reply editor to add the code tags and then save the reply
Do all of this, because the only hope any of us have of identifying your problem for you, is by either interpreting the error message you haven’t posted yet, or by copy-pasting your code into our IDE, and then compiling to see the results.
Thanks
See this following example, on line 1... my error indicates I tried to initialize and assign a value to (int B1 = 1;) a pre-defined variable (something used in the "core" library, like #define B1 0b1), where ALL CAPS are used for defining replacement values, for example, the #define B1 0b1 replaces all B1 occurances with 0b1...
This simple sketch...
int B1 = 1; // this will cause an error because B1 is a pre-defined macro
void setup() {
// nothing here
}
void loop() {
// nothing here
}
Causes the error...
In file included from /arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h:32:0,
from sketch.ino.cpp:1:
/arduino/hardware/avr/1.8.6/cores/arduino/binary.h:31:12: error: expected unqualified-id before numeric constant
#define B1 1
^
sketch.ino:1:5: note: in expansion of macro 'B1'
int B1 = 1;
^~
Error during build: exit status 1
The error above, toward the bottom, says sketch.ino:1:5 did something wrong on LINE 1, COLUMN 5: and refers to 'B1'... then "points" to the error with this "^-"
This is where the "core" has the definition (in the error above, extracted here...)
/arduino/hardware/avr/1.8.6/cores/arduino/binary.h:31:12: error: expected unqualified-id before numeric constant
#define B1 1
You can see the core has B1 pre-defined.
My guess (in this example) is that "B1" is referring to binary digit, of the value "1"
Check your sketch for any ALL CAPS variables... and change them to lower case.