Can't compile code with libraries - stepper and IRremote

I have not used libraries before so probably something easy.

I am trying to get the remote control working on my Super Starter Kit UNO R3 Project.

I installed the 2 library in question or so I thought and they show up in Sketch -> Include Library.

Running MAC OS Big Sur 11.2.3.

Running Arduino Genuino 1.8.13.

Any help appreciated.

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccsFfSM6.ltrans0.ltrans.o: In function setup': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:22: undefined reference to IRrecv::enableIRIn()'
/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccsFfSM6.ltrans0.ltrans.o: In function loop': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:27: undefined reference to IRrecv::decode(decode_results*)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:35: undefined reference to Stepper::setSpeed(long)' /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:44: undefined reference to Stepper::step(int)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:50: undefined reference to IRrecv::resume()' /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:42: undefined reference to Stepper::setSpeed(long)'
/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccsFfSM6.ltrans0.ltrans.o: In function __static_initialization_and_destruction_0': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:16: undefined reference to Stepper::Stepper(int, int, int, int, int)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:17: undefined reference to `IRrecv::IRrecv(int)'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

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

Please tell us which libraries you installed. And please show your code.

Sorry, here is the code (came with kit or is Arduino public)...

//www.elegoo.com
//2016.12.12

#include "Stepper.h"
#include "IRremote.h"

/----- Variables, Pins -----/
#define STEPS 32 // Number of steps per revolution of Internal shaft
int Steps2Take; // 2048 = 1 Revolution
int receiver = 12; // Signal Pin of IR receiver to Arduino Digital Pin 6

/-----( Declare objects )-----/
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4

Stepper small_stepper(STEPS, 8, 10, 9, 11);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'

void setup()
{
irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?

{
switch(results.value)

{

case 0xFFA857: // VOL+ button pressed
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 2048; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
break;

case 0xFF629D: // VOL- button pressed
small_stepper.setSpeed(500);
Steps2Take = -2048; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
break;

}

irrecv.resume(); // receive the next value
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}

}/* --end main loop -- */

2 libraries are Stepper and IRremote...

Try changing this line:

#include "Stepper.h"

to:

#include <Stepper.h>

Then compile again. Do you still get the same error messages?

So I get different errors with each of the following combos of using "" versus <> for the included files

"Stepper.h"
"IRremote.h"

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccbDTdRw.ltrans0.ltrans.o: In function setup': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:22: undefined reference to IRrecv::enableIRIn()'
/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccbDTdRw.ltrans0.ltrans.o: In function loop': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:27: undefined reference to IRrecv::decode(decode_results*)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:35: undefined reference to Stepper::setSpeed(long)' /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:44: undefined reference to Stepper::step(int)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:50: undefined reference to IRrecv::resume()' /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:42: undefined reference to Stepper::setSpeed(long)'
/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccbDTdRw.ltrans0.ltrans.o: In function __static_initialization_and_destruction_0': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:16: undefined reference to Stepper::Stepper(int, int, int, int, int)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:17: undefined reference to `IRrecv::IRrecv(int)'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

#include <Stepper.h>
#include "IRremote.h"

/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccs4WZmY.ltrans0.ltrans.o: In function setup': /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:22: undefined reference to IRrecv::enableIRIn()'
Multiple libraries were found for "Stepper.h"
/var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccs4WZmY.ltrans0.ltrans.o: In function loop': Used: /Users/johnheffernan/Documents/Arduino/libraries/Stepper Not used: /Applications/Arduino.app/Contents/Java/libraries/Stepper /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:27: undefined reference to IRrecv::decode(decode_results*)'
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:50: undefined reference to IRrecv::resume()' /var/folders/0z/wf0s01md3yd_lc2vy_m4t_vh0000gp/T//ccs4WZmY.ltrans0.ltrans.o: In function __static_initialization_and_destruction_0':
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:17: undefined reference to `IRrecv::IRrecv(int)'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

#include <Stepper.h>
#include <IRremote.h>

/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino: In function 'void loop()':
/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:27:27: warning: 'bool IRrecv::decode(decode_results*)' is deprecated: Please use decode() without a parameter. [-Wdeprecated-declarations]
if (irrecv.decode(&results)) // have we received an IR signal?
^
In file included from /Users/johnheffernan/Documents/Arduino/libraries/IRremote/src/IRremote.h:183:0,
from /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/With_Remote/With_Remote.ino:5:
/Users/johnheffernan/Documents/Arduino/libraries/IRremote/src/IRReceive.cpp.h:1354:6: note: declared here
bool IRrecv::decode(decode_results *aResults) {
^~~~~~
Sketch uses 8216 bytes (25%) of program storage space. Maximum is 32256 bytes.
Global variables use 589 bytes (28%) of dynamic memory, leaving 1459 bytes for local variables. Maximum is 2048 bytes.

This tells me that you copied Stepper.h and IRremote.h into the /Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/ folder in a misguided attempt to fix the "No such file or directory" errors. I recommend you to delete those files from the sketch folder so they won't cause any further confusion.

The reason you get different results between the "" and <> syntaxes is because "" causes the local path (/Users/johnheffernan/Desktop/Elegoo The Most Complete Starter Kit for UNO V2.0.2020.7.17/English/Part 3 Multi-module Combination Course/3.7 Controlling a Stepper Motor With Remote/ in this case) to be searched for the header file, only then checking the libraries folders if it's not found in the sketch folder. When you use the <> syntax, the local path is not searched, so it is able to find the file in the installed libraries.

Note that the result when you use all <> is only a warning, not an error. So you should be able to use the sketch without any problems now.

Great explanation. Thanks!

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

Looks like the library changed but the sample code that changed it did not so I am going to try and figure out how to call it correctly, where library data structures and functions are defined and documented, etc.

Getting a 0 on the return value and constant warning in serial monitor but it is registering that it (Arduino) received a code from the IR receiver/remote so it's a start.

So now I see why things were so FUBAR.

Looks like there are 2 identically named libraries for IR I was using. The sample code I got with the ELEGOO SuperStarter kit was using was actually trying to call the classes from what looks like a more built in IR library of the same name.

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