Using & Learning IDE with faulty code examples found online

I have been working with the IDE code intermittently for a year or so, but all of my programming work has really been with Air Manager LUA scripting. Most of that LUA scripting has been provided by others online.
The IDE stuff I work on is nothing more than finding code online and copying it without really understanding what everything within the code or within the error messages really mean. I don't think I will ever become a programmer, but I can do the hardware work.
Currently, I am working on building a flight sim radio that will be programmed in air manager, but I wanted to play around with the 7-segment displays that I will be using for the frequency display.
(Still trying to understand the 7-segment display pinouts)
So I found an example of how to wire up a 4 digit display along with what is supposed to be the code to drive it.
But as is the case sometimes those code examples I find online do not work and I get error messages when I try to upload to my Arduino UNO.
And with me not being a programmer, I do not know how to debug the code that I find that obviously isn't completely correct. There is one error messages that eludes me which I pared down from several errors once I straightened out some of the punctuation that was incorrect in the example.
Trying to debug posted code that has some errors is a real pita for noobs like me who don't know how to actually write programs.
So what would be my next step in trying to debug an error still left in the code that I found as part of a MAX7219 and 7-segment display wiring example?

Post the full sketch here and the full error messages, both in code tags

A schematic of your project would also be helpful. A photo of a hand drawn circuit is good enough or a link to it online

Can I post the image of the schematic from the website as a .jpg or .png I can create from a snipit?
I retyped the code from the website example into an IDE sketch and then made a couple of punctuation changes just by hit or miss.
Should I post the original code? I'd like to understand what the original errors were all about before I made the few punctuation changes. Since I am not sure what I actually did...
But I can also post the revised sketch that now has the one error message.

Why not post a link to the website ?

It is easy to make mistakes that way. Could you not copy the code from the website ?

Post your revised code and a link to where you got the original sketch

You presume the posted code was in error; something unproven.

Much posted code also includes Q/A at the end and many errors are corrected within that feedback.

may want to look at the Multifunction shield, both schematic and code

I can just post a link to the website...if that is okay with the internet police.

Let me go find the info on how to do the code blocks and I can post the errors I get.

This is the original code copied from the site linked to and Auto formatted in the IDE

#include <SPI.h>

const int slaveSelect = 10; //pin used to enable the active slave

const int numberofDigits = 2;

const int maxCount = 99;

int number = 0;

void setup()
{
  Serial.begin(9600);
  SPI.begin(); //initialize SPI
  pinMode(slaveSelect, OUTPUT);
  digitalWrite(slaveSelect, LOW); //select Slave
  //prepare the 7219 to display 7-segment data
  sendCommand (12, 1); //normal mode (default is shutdown mode)
  sendCommand (15, 0); //Display test off
  sendCommand (10, 8); //set medium intensity (range is 0-15)
  sendCommand (11, numberofDigits); //7219 digit scan limit command
  sendCommand (9, 255); //decode command, use standard 7-segment digits
  digitalWrite(slaveSelect, HIGH); //deselect slave
}

void loop()
{
  //display a number from serial port terminated by end of line character
  if (Serial.available())
  {
    char ch = Serial.read();
    if (ch == '\n')
    {
      displayNumber(number);
      number = 0;
    }
    else
      number = (number * 10) + ch - '0';
  }
}

//function to display up to 4 digits on a 7-segment display
void displayNumber (int number)
{
  for (int i = 0; i < numberofDigits; i++)
  {
    byte character = number % 10; //get the value of the rightmost digit
    if (number == 0 && i > 0)
      character = 0xf;
    sendCommand(numberofDigits - i, character);
    number = number / 10;
  }
}

void sendCommand(int command, int value)
{
  digitalWrite(slaveSelect, LOW); //chip select is active low
  SPI.transfer(command);
  SPI.transfer(value);
  digitalWrite(slaveSelect, HIGH);
}

Throwing random crap at the wall to see what sticks is a poor way to program and typically leads to nothing but frustration. My advice is to take the time and learn some rudimentary coding.

1 Like

I am still trying to figure out how to place the error messages inside the </>.
Since there is no post preview I am not sure if what I am doing is correct.

The first time I did this code I just typed each line and double and triple checked that it matched the code on the website. Then just now I copied and pasted the text directly from the website.
Each time I get different errors...so maybe I thought I had it exact the first time but didn't.

Is this posting of the error messages correct? I can't tell without a preview....

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

sketch_dec30c:1:1: error: 'Code' does not name a type; did you mean 'tone'?

 Code

 ^~~~

 tone

In file included from C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_375570\sketch_dec30c.ino:6:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:178:39: error: 'SPISettings' has not been declared

   inline static void beginTransaction(SPISettings settings) {

                                       ^~~~~~~~~~~

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::beginTransaction(int)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:203:21: error: request for member 'spcr' in 'settings', which is of non-class type 'int'

     SPCR = settings.spcr;

                     ^~~~

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:204:21: error: request for member 'spsr' in 'settings', which is of non-class type 'int'

     SPSR = settings.spsr;

                     ^~~~

exit status 1

'Code' does not name a type; did you mean 'tone'?



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Did you check?

That's easy
Copy the error message from the IDE using the "Copy error message" button. In a forum post click the </> button above the edit window and past the error messages in where indicated between the 2 groups of backticks

Now we need to see your version of the code. Copy it from the IDE using "Copy for Forum" and the code tags will be added automatically ready to post it here

I have been trying to learn rudimentary coding over the last year. A youtube coding series I went through was from Paul McWhorter.
I am not trying to become a bonafide programmer. I just need to learn enough to get this home flight sim completed. After that I probably will never do any coding.
For now I just wanted a good IDE sketch to play around with the 7-segment display.

I dont know anything about the "verbose" thing...I will go back and look.

I selected the "copy error message" button in the orange bar between the code and the errors.
Then I select the </> at the top of the forum post and pasted the copied info in there.

I don't see anything about the "verbose" option. I am trying it again.
Not having a preview button for my posts is a bit of a handicap.

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

sketch_dec30c:1:1: error: 'Code' does not name a type; did you mean 'tone'?

 Code

 ^~~~

 tone

In file included from C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_375570\sketch_dec30c.ino:6:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:178:39: error: 'SPISettings' has not been declared

   inline static void beginTransaction(SPISettings settings) {

                                       ^~~~~~~~~~~

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::beginTransaction(int)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:203:21: error: request for member 'spcr' in 'settings', which is of non-class type 'int'

     SPCR = settings.spcr;

                     ^~~~

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:204:21: error: request for member 'spsr' in 'settings', which is of non-class type 'int'

     SPSR = settings.spsr;

                     ^~~~

exit status 1

'Code' does not name a type; did you mean 'tone'?



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Found the verbose setting....

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\kaell\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\kaell\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaell\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\kaell\AppData\Local\Temp\arduino_build_986029 -warnings=none -build-cache C:\Users\kaell\AppData\Local\Temp\arduino_cache_971579 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_247299\sketch_dec30c.ino

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\arduino-builder -compile -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\kaell\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\kaell\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaell\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\kaell\AppData\Local\Temp\arduino_build_986029 -warnings=none -build-cache C:\Users\kaell\AppData\Local\Temp\arduino_cache_971579 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_247299\sketch_dec30c.ino

Using board 'uno' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\sketch\\sketch_dec30c.ino.cpp" -o nul

Alternatives for SPI.h: [SPI@1.0]

ResolveLibrary(SPI.h)

  -> candidates: [SPI@1.0]

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\sketch\\sketch_dec30c.ino.cpp" -o nul

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src\\SPI.cpp" -o nul

Generating function prototypes...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\sketch\\sketch_dec30c.ino.cpp" -o "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\sketch\\sketch_dec30c.ino.cpp" -o "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_986029\\sketch\\sketch_dec30c.ino.cpp.o"

sketch_dec30c:3:1: error: 'Code' does not name a type; did you mean 'tone'?

 Code

 ^~~~

 tone

C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_247299\sketch_dec30c.ino: In function 'void setup()':

sketch_dec30c:22:9: error: 'slaveSelect' was not declared in this scope

 pinMode(slaveSelect, OUTPUT);

         ^~~~~~~~~~~

C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_247299\sketch_dec30c.ino: In function 'void sendCommand(int, int)':

sketch_dec30c:64:14: error: 'slaveSelect' was not declared in this scope

 digitalWrite(slaveSelect, LOW); //chip select is active low

              ^~~~~~~~~~~

Using library SPI at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI 

exit status 1

'Code' does not name a type; did you mean 'tone'?


We still seem to be missing your version of the code

Here is what I typed out in trying to copy the code from the website...
From what I can tell this is exactly the same....

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\kaell\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\kaell\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaell\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\kaell\AppData\Local\Temp\arduino_build_486274 -warnings=none -build-cache C:\Users\kaell\AppData\Local\Temp\arduino_cache_971579 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_913965\sketch_dec30d.ino

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\arduino-builder -compile -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\kaell\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\kaell\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaell\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\kaell\AppData\Local\Temp\arduino_build_486274 -warnings=none -build-cache C:\Users\kaell\AppData\Local\Temp\arduino_cache_971579 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\kaell\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_913965\sketch_dec30d.ino

Using board 'uno' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\sketch\\sketch_dec30d.ino.cpp" -o nul

Alternatives for SPI.h: [SPI@1.0]

ResolveLibrary(SPI.h)

  -> candidates: [SPI@1.0]

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\sketch\\sketch_dec30d.ino.cpp" -o nul

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src\\SPI.cpp" -o nul

Generating function prototypes...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\sketch\\sketch_dec30d.ino.cpp" -o "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Program Files\\WindowsApps\\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\sketch\\sketch_dec30d.ino.cpp" -o "C:\\Users\\kaell\\AppData\\Local\\Temp\\arduino_build_486274\\sketch\\sketch_dec30d.ino.cpp.o"

sketch_dec30d:3:1: error: 'Code' does not name a type; did you mean 'tone'?

 Code

 ^~~~

 tone

C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_913965\sketch_dec30d.ino: In function 'void setup()':

sketch_dec30d:22:13: error: 'slaveSelect' was not declared in this scope

     pinMode(slaveSelect, OUTPUT);

             ^~~~~~~~~~~

sketch_dec30d:25:5: error: 'sendCommand' was not declared in this scope

     sendCommand(12,1);

     ^~~~~~~~~~~

C:\Users\kaell\AppData\Local\Temp\arduino_modified_sketch_913965\sketch_dec30d.ino: At global scope:

sketch_dec30d:34:3: error: expected initializer before 'if'

   if(Serial.available())

   ^~

sketch_dec30d:45:3: error: expected declaration before '}' token

   }

   ^

Using library SPI at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI 

exit status 1

'Code' does not name a type; did you mean 'tone'?


That looks more like the error message than your sketch

Previous post ws the error messages

This is the code I typed in....

#include <SPI.h>

Code

This code displays a number from 0 to 9999 on a four-digit display


#include <SPI.h>

const int slaveSelect= 10;

const int numberofDigits= 2;

const int maxCount= 99;

int number=0;

void setup()
  {
    Serial.begin(9600);
    SPI.begin();
    pinMode(slaveSelect, OUTPUT);
    digitalWrite(slaveSelect, LOW);

    sendCommand(12,1);
    sendCommand(15,0);
    sendCommand(10,8);
    sendCommand(11,numberofDigits);
    sendCommand(9,255);
    digitalWrite(slaveSelect, HIGH);
  }

void loop()
  if(Serial.available())
  {
    char ch= Serial.read();
    if (ch == '\n')
  {
    displayNumber(number);
    number=0;
}
    else
    number= (number * 10) + ch - '0';
  }
  }

  void displayNumber (int number)
  {
    for (int i=0; i < numberofDigits; i++)
  {
    byte character= number % 10;
    if (number == 0 && i > 0)
    character = 0xf;
    sendCommand(numberofDigits-i, character);
    number= number/10;
  }
  }

  void sendCommand(int command, int value)
  {
    digitalWrite(slaveSelect, LOW);
    SPI.transfer(command);
    SPI.transfer(value);
    digitalWrite(slaveSelect,HIGH);
  }