program won't compile

i can not figure out my code compile. it all looks right to me but i am new to this!

please help!!

thanks in advance.

#include <Stepper.h>
#include <Keypad.h>

const byte ROWS = 4;       // set display to 4 rows.
const byte COLS = 3;       // ste display to 3 columns.
char keys[ROWS][COLS] =
{ {'1', '2', '3'},
  {'4', '5', '6'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {7, 6, 5, 4};
byte colPins[COLS] = {10, 9, 8};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

const int stepsPerRev = 32;   // steps per revolution.
const int B1 = 11;            // pushbutton 1, to unlock.
const int B2 = 12;            // pushbutton 2, to lock.

Stepper myStepper(stepsPerRev, 0, 1, 2, 3);

void setup() {
  pinMode(B1, INPUT);
  pinMode(B2, INPUT);
}


void loop() {
  if (B1 == HIGH) {
    myStepper.setSpeed(20);
  }
  else if (B2 == HIGH) {
    myStepper.setSpeed(-20);
  }

}

When it doesn't compile, there are error messages. Or did you want us to guess?

See the difference?

if (digitalRead(B1) == HIGH) { . . . }

This is an odd one. The error message

/Applications/Arduino 1.8.0.app/Contents/Java/hardware/arduino/avr/cores/arduino/binary.h:31:12: error: expected unqualified-id before numeric constant
 #define B1 1
            ^
/var/folders/pr/xbl5ybq10m16h7mq622b75z80000gn/T/arduino_modified_sketch_533312/sketch_may29a.ino:16:11: note: in expansion of macro 'B1'
 const int B1 = 11;            // pushbutton 1, to unlock.

tells me that the file binary.h uses a #define for B1, so in your code it is expanding to :

 const int 1 = 11;

If you change the variable names to Button1 and Button2 (or, I suggest, lockButtonPin and unlockButtonPin) then it should compile.

As LarryD points out it will not work, though, since you are comparing the pin number to a pin state.

this is the error message i am getting

"exit status 1 Error compiling for board Arduino/Genuino Uno."

WhiteT:
this is the error message i am getting

“exit status 1
Error compiling for board Arduino/Genuino Uno.”

No, that’s just the useless fragment of the error output that you happen to see because you didn’t bother to scroll up to see all the rest of it. When you see a scroll bar on the side of a window that means there is more content that wouldn’t fit in the window. You can use your mouse to move that scroll bar. You can also use your mouse to resize the window so that more output fits in it at one time.

When you encounter an error you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\thoma\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10800 -build-path C:\Users\thoma\AppData\Local\Temp\arduino_build_967286 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\thoma\Documents\Arduino\doorLock\dookLock\dookLock.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\thoma\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10800 -build-path C:\Users\thoma\AppData\Local\Temp\arduino_build_967286 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\thoma\Documents\Arduino\doorLock\dookLock\dookLock.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "C:\Program Files (x86)\Arduino\libraries\Stepper\src\Stepper.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad\utility" "C:\Users\thoma\Documents\Arduino\libraries\Keypad\Keypad.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad\utility" "C:\Users\thoma\Documents\Arduino\libraries\Keypad\utility\Key.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp" -o "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os  -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\libraries\Stepper\src" "-IC:\Users\thoma\Documents\Arduino\libraries\Keypad" "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp" -o "C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp.o"
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:32:0,

                 from C:\Users\thoma\AppData\Local\Temp\arduino_build_967286\sketch\dookLock.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/binary.h:31:12: error: expected unqualified-id before numeric constant

 #define B1 1

            ^

C:\Users\thoma\Documents\Arduino\doorLock\dookLock\dookLock.ino:16:11: note: in expansion of macro 'B1'

 const int B1 = 12;            // pushbutton 1, to unlock.

           ^

Using library Stepper at version 1.1.3 in folder: C:\Program Files (x86)\Arduino\libraries\Stepper 
Using library Keypad in folder: C:\Users\thoma\Documents\Arduino\libraries\Keypad (legacy)
exit status 1
Error compiling for board Arduino/Genuino Uno.

Nice! I think the problem has already been explained to you in the previous replies but learning how to view the full output and how to post that output to the forum correctly are very useful skills.

Here's a tip: Even though the IDE will tell you otherwise, I actually find that enabling File > Preferences > Show verbose output during compilation usually just clutters up the output without adding useful information so I almost always leave it off. The majority of the verbose output is useful only for troubleshooting very rare bugs that have nothing to do with your code. The exception is the "Using library" messages, which can be extremely helpful. Unfortunately in the last release they decided to move those the the verbose output.

On the other hand, I find enabling File > Preferences > Show verbose output during upload to be very useful and I always leave that enabled. Even when the upload is successful, I like to see the progress of the upload so I know that something is actually happening.

Hi,

Stepper myStepper(stepsPerRev, 0, 1, 2, 3);

If 0, 1, 2, 3 are the stepper output pins.

Pins 0 and 1 are the programming pins and you will after successful compilation have problems with your code running on the Arduino.

Tom.... :)

As Blue Eyes explained in post#3 This doesn't compile.

byte B1 = 11;

void setup() {
}

void loop() {
}

This does.

byte Button1 = 11;

void setup() {
}

void loop() {
}

Leo..

Hi,
This is your code tidied up with logical pin and variable names.
It compiles for UNO, IDE 1.8.0, Win7

#include <Stepper.h>
#include <Keypad.h>

const byte ROWS = 4;       // set display to 4 rows.
const byte COLS = 3;       // ste display to 3 columns.
char keys[ROWS][COLS] =
{ {'1', '2', '3'},
  {'4', '5', '6'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {7, 6, 5, 4};
byte colPins[COLS] = {10, 9, 8};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

const int stepsPerRev = 32;   // steps per revolution.
const int B1pin = 11;            // pushbutton 1, to unlock.
const int B2pin = 12;            // pushbutton 2, to lock.

bool B1status = false; // status of B1 button
bool B2status = false; // status of B2 button

Stepper myStepper(stepsPerRev, 0, 1, 2, 3);

void setup() {
  pinMode(B1pin, INPUT);
  pinMode(B2pin, INPUT);
}


void loop() {
  B1status = digitalRead(B1pin);
  B2status = digitalRead(B2pin);
  if (B1status == HIGH) {
    myStepper.setSpeed(20);
  }
  else if (B2status == HIGH) {
    myStepper.setSpeed(-20);
  }

}

Tom… :slight_smile: