When I try to upload a sketch it gives me Compilation error

As the title says I have an error I have pretty much spent the past 2 days looking at almost every forum post on this I have tried almost everything. I really need this to work because I have a project that needs to be done.

Here is the code:

#define STEPPER_PIN_1 9
#define STEPPER_PIN_2 10
#define STEPPER_PIN_3 11
#define STEPPER_PIN_4 12
int step_number = 0;
void setup() {
  // put your setup code here, to run once:
pinMode(STEPPER_PIN_1, OUTPUT);
pinMode(STEPPER_PIN_2, OUTPUT);
pinMode(STEPPER_PIN_3, OUTPUT);
pinMode(STEPPER_PIN_4, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  OneStep(false);
  delay(2);
}

void OneStep(bool dir){
  if(dir){
switch(step_number){
  case 0:
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    case 1:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    case 2:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    case 3:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  break;
}
  }else{
    switch(step_number){
    case 0:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  break;
    case 1:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    case 2:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    case 3:
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
    }
    }
step_number++;
  if(step_number > 3){
    step_number = 0;
  }
  }


Welcome to the forum

The sketch compiles OK for me

Please post the full error message, using code tags when you do

Which Arduino board are you using ?

I am using an Elegoo uno but it can just be a ration uno I am kind of a noob at this

This is the whole error messege

FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

loading library from C:\Users\texas\OneDrive\Documents\Arduino\libraries\package-2531440388: invalid library: no header files found
Detecting libraries used...
C:\Users\texas\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\texas\AppData\Local\Temp\arduino\sketches\703DFD14AB640E915B77CEBD06E871AF\sketch\steppermotor.ino.cpp -o nul
Generating function prototypes...
C:\Users\texas\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\texas\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\texas\AppData\Local\Temp\arduino\sketches\703DFD14AB640E915B77CEBD06E871AF\sketch\steppermotor.ino.cpp -o C:\Users\texas\AppData\Local\Temp\3688291178\sketch_merged.cpp
C:\Users\texas\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\texas\AppData\Local\Temp\3688291178\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\texas\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\texas\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\texas\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF\\sketch\\steppermotor.ino.cpp" -o "C:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF\\sketch\\steppermotor.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\texas\AppData\Local\Temp\arduino\cores\arduino_avr_uno_4efd6f3ace9e2d9ef704adb03bc403de\core.a
Linking everything together...
"C:\\Users\\texas\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF/steppermotor.ino.elf" "C:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF\\sketch\\steppermotor.ino.cpp.o" "C:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF/..\\..\\cores\\arduino_avr_uno_4efd6f3ace9e2d9ef704adb03bc403de\\core.a" "-LC:\\Users\\texas\\AppData\\Local\\Temp\\arduino\\sketches\\703DFD14AB640E915B77CEBD06E871AF" -lm
c:/users/texas/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'

exit status 1

Compilation error: exit status 1

Hi,
Welcome to the forum.

What IDE version?
What OS?

Have you been able to load other code to your controller?
Such as "Blink without delay" in the Examples folder.

Tom.. :grinning: :+1: :coffee: :australia:

A quick forum search turned up this possible solution:

3 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.