It seems like it doesn't like me to use the names CS10, CS11 and CS12. Why is that?
most likely because those names have already been #defined as something.
It seems to me that anyway you should be using an array to hold the pin numbers.
There is no hard and fast rules but variables whose name is in capitals are generally constants or macros and that includes those defined by the Arduino system itself
In this case it would appear that CS10 and the other troublesome names are already defined
Try printing CS10, CS11 and CS12 without even declaring them and you will see values of 0, 1 and 2. So, when the compiler sees
Deva_Rishi:
most likely because those names have already been #defined as something.
It seems to me that anyway you should be using an array to hold the pin numbers.
I have deleted all the code except the excerpt that I have posted here, but I still got the error.
Here are the definitions of CS10, CS11, CS12 in the avr-libc component of the AVR toolchain:
#define CS12 2
#define CS11 1
#define CS10 0
One of the things I think is really cool about Arduino IDE 2.x is it has this "Go to definition" option in the context menu. So you can right click on some part of the code you're curious about and then take a look at its source code! I think it can be a really valuable learning tool. This is a feature we take for granted in advanced IDEs for other languages, but it has not been available at this level of functionality for the Arduino language before now.
With the classic Arduino IDE, my trick for investigating the source of macro definitions was to define it to some value I knew would be different from the original in order to trigger a redefinition warning, which shows the location of the original definition. If you compile this sketch with compiler warnings enabled in File > Preferences:
#define CS10 foo
void setup() {}
void loop() {}
You get a warning something like this in the black console pane at the bottom of the Arduino IDE window:
C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_268986\sketch_apr04a.ino:1:0: warning: "CS10" redefined
#define CS10 foo
In file included from c:\users\per\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\iom2560.h:38:0,
from c:\users\per\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:174,
from c:\users\per\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\pgmspace.h:90,
from C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino/Arduino.h:28,
from C:\Users\per\AppData\Local\Temp\arduino_build_68419\sketch\sketch_apr04a.ino.cpp:1:
c:\users\per\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\iomxx0_1.h:722:0: note: this is the location of the previous definition
#define CS10 0
CS10, CS11, and CS12 are the names of the three "Clock Select" bits in TCCR1B (Timer/Counter Control Register B for Timer/Counter 1). Similarly CS20, CS21, and CS22 are for Timer2 and CS00, CS01, and CS02 are for Timer0.