Arduino not recognizing "AFmotor.h"
Moderators: adafruit_support_bill, adafruit

Arduino not recognizing "AFmotor.h"

by messygarage on Mon Nov 05, 2012 6:24 pm

Help, I'm using a Arduino Uno rev 3 and a Motor shield kit version 1.1 (products 81). I've downloaded both of the AF motor library and the AccelStepper to the proper libraries, changed the foldernames and also changed the M to m in the AFmotor. When I load the examples, the AFmotor.h is not recognized ( AFmotor is not highlighted in the #include <AFmotor.h statement). I've tried this using both IDE 1.0 and also 1.01. The serial monitor is showing the program running properly, but there is no voltage change on the M3 and M4 terminals. I am using an external power supply with the jumper moved to the open position and the green power light is lit. I've also tried the 2 different master libraries listed in the manuals. Is there anything else I need to download to get this to work? Any ideas would be appreciated
messygarage
 
Posts: 2
Joined: Mon Nov 05, 2012 6:03 pm

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Mon Nov 05, 2012 6:44 pm

The reference to the motor library should be:

#include <AFMotor.h>

A folder of the same name, AFMotor, containing an example folder and the .h and .cpp files should be in the Library folder within the Arduino 1.0.1 folder. That's how mine is set up.
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by adafruit_support_rick on Mon Nov 05, 2012 7:32 pm

@Arctic_Eddie -
Actually, that's incorrect.

@messygarage -
User libraries should be stored in a folder called "libraries" within the sketch folder. You should not be storing them inside the arduino 1.0.1 folder.

You can find out the path to the sketch folder by opening File:Preferences (Arduino:Preferences in MacOS) and looking at "Sketchbook Location"

If there is not already a folder called "libraries" in the sketchbook folder, you must create one. Your AFMotor folder goes inside of that.

#include "AFMotor.h" is the correct way to include user libraries (i.e., quote marks, not angle brackets)

Note that capitalization is important. The library folder must have the exact same name as the library file inside.

More information on libraries is available in our tutorial!

adafruit_support_rick
 
Posts: 14496
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Mon Nov 05, 2012 9:08 pm

Mine are all in c:\users\xxxx\downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries. This is where all the default libraries were created when the program was installed. The same thing happened with V1.0.0 and V022. The sketch folder is in c:\users\xxxx\documents\arduino\projects. I selected the name and location when saving the first sketch. There is no folder named sketch. The preferences.txt file points correctly to the two locatons. There is another folder named libraries within c:\users\xxxx\documents\arduino\ at the same level as projects but it contains only a readme.txt. The default libraries were never in this folder. I added new ones in the same as the defaults. All my sketches work fine in all three versions of the IDE so I hesitate making any changes. It's true though that each version of the IDE has it's own libraries folder and when I install a new version I have to copy over the content of the previous version. If they were in the libraries folder in documents then I might need only one copy for all versions. However, the path statements would have to be altered. I'll keep it like it is now until I find reason to change.

PS
I found examples using both the <> and "" terminology. I've used both ways, even mixed in the same sketch, and find them equally effective.

PPS
Here's the first five text lines from your graphicstest.ino example for the 2.8" TFT. All recent examples I've seen use the <> method.

quote
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
endquote
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by adafruit_support_bill on Mon Nov 05, 2012 10:03 pm

Mine are all in c:\users\xxxx\downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries.

That is where all the default libraries are located. Adding additional libraries there will work . . . But only until the next release of the Arduino software. Then it will be necessary to re-install all your downloaded libraries in the new Arduino installation too.

Libraries installed in the Libraries folder of your sketchbook folder will be usable with all future versions of the Arduino package without the need to re-install.
User avatar
adafruit_support_bill
 
Posts: 32625
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Mon Nov 05, 2012 10:13 pm

I've copied all the library folders from the installation area to the document/arduino area. Will add any new ones to that location only and see if it's ok. Yes, I did copy library folders to new version installations. And yes, I see they would be available to new versions if installed in the documents/arduino/libraries folder. The executable folder is apparently in one of the paths so I assume that's how the compiler found them.
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by messygarage on Mon Nov 05, 2012 10:38 pm

Would you believe it was a bad arduino board, that was giving me all of the grief. I changed it out and my stepper is happily moving back and forth now. I did try the "" instead of the brackets, but that resulted in the AF_Stepper not valid. Thank you everyone for your fast help.
messygarage
 
Posts: 2
Joined: Mon Nov 05, 2012 6:03 pm

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Tue Nov 06, 2012 9:22 am

That's strange. I just tried my telescope focuser sketch with both <> and "" and it compiles with either choice. The AF_Stepper line works OK. I'm using V1.0.1 IDE. Since you found a way to make it work then that's great.
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by adafruit_support_rick on Wed Nov 07, 2012 11:41 am

The C convention for the #include syntax is that header files in quotes are assumed to be user files, and headers in angle brackets are assumed to be system files.

It should affect which paths are searched first. For example, the adafruit SD library has the same name as the standard SD library. #include <SD.h> should search the default arduino library first, and find the standard library. #include "SD.h" should find the adafruit library first.

However, I just did some experiments, and Arduino doesn't seem to follow this convention at all. It always searches the user library path first.

adafruit_support_rick
 
Posts: 14496
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Wed Nov 07, 2012 7:59 pm

System vs Adafruit, is that the reason some file names show up red while others are black in the IDE? If so, that would be a good way to know whether to use <> or "".
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by adafruit_support_rick on Thu Nov 08, 2012 11:18 am

References to the built-in libraries do appear to be highlighted in red. What about the user libraries you put into the system? Did they show up red?
In any case, the answer here seems to be that, in arduino, makes no difference whether you use <> or "". They are equivalent.

adafruit_support_rick
 
Posts: 14496
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Thu Nov 08, 2012 2:41 pm

These are my libraries for the metal detector project. Only Wire and EEPROM are in red. Since there is only one master folder containing libraries, how would the IDE distinguish between system and user libraries? Since they're all in one master folder then perhaps there's no reason or way to separate the two library types and hence the same action for <> and "".

#include <Wire.h> // Serial wire line comm
#include <ffft.h> // Fast fourier transform functions
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h> // Touchscreen driver
#include <stdint.h> // Integer types
#include <EEPROM.h> // Basic EEPROM
#include <EEPROMAnything.h> // Read/write any structure var to EEPROM
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL

Re: Arduino not recognizing "AFmotor.h"

by adafruit_support_bill on Thu Nov 08, 2012 2:46 pm

The 'red' highlighting comes from keywords defined in "keywords.txt" in each library folder. If there is no keywords.txt, or the library name is not a keyword, it will not be highlighted.
User avatar
adafruit_support_bill
 
Posts: 32625
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino not recognizing "AFmotor.h"

by Arctic_Eddie on Thu Nov 08, 2012 2:58 pm

Thanks for the clarification.
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 6:01 pm
Location: St. Petersburg, FL