i made my first .h & .cpp files. i created a folder "Morse" in Libraries, and then put them in the subdirectory "src"
but when i do: #include
but arduino IDE isn't recognizing it.
i made my first .h & .cpp files. i created a folder "Morse" in Libraries, and then put them in the subdirectory "src"
but when i do: #include
but arduino IDE isn't recognizing it.
In the Arduino IDE, navigate to Sketch > Include Library. At the top of the drop down list, select the option to "Add .ZIP Library''.
made my first .h & .cpp files
What are there names of the files ? They must match the folder name exactly
i created a folder "Morse" in Libraries,
Which of the libraries folders ? The one in the Arduino system folder or the one in the Arduino sketches folder ? The latter is the correct one
and then put them in the subdirectory "src"
Whey did you put them in s subdirectory ?
#include <Morse>
That should be
#include <Morse.h>
assuming that you have named the files correctly
After installing your library files did you stop/start the IDE ?
If you do Sketch/Import library can you see your library listed ? If not then neither can the compiler.
so i created a folder in my arduino sketch folder and put the files there. is this right?
to zax: it's not a zip
bmarconi:
so i created a folder in my arduino sketch folder and put the files there. is this right?to zax: it's not a zip
Manual installation
To install the library, first quit the Arduino application.
Then uncompress the ZIP file containing the library. For example, if you're installing a library called "ArduinoParty", uncompress ArduinoParty.zip. It should contain a folder called ArduinoParty, with files like ArduinoParty.cpp and ArduinoParty.h inside. (If the .cpp and .h files aren't in a folder, you'll need to create one. In this case, you'd make a folder called "ArduinoParty" and move into it all the files that were in the ZIP file, like ArduinoParty.cpp and ArduinoParty.h.)
Drag the ArduinoParty folder into this folder (your libraries folder). Under Windows, it will likely be called "My Documents\Arduino\libraries". For Mac users, it will likely be called "Documents/Arduino/libraries". On Linux, it will be the "libraries" folder in your sketchbook.
Your Arduino library folder should now look like this (on Windows):
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.cpp
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.h
My Documents\Arduino\libraries\ArduinoParty\examples
It's not zip because you din't zip it..So, if its not a zip(because you don't wont to zip it
), follow the above manual installation steps..
**Source:**http://arduino.cc/en/guide/libraries#toc5
and then i went to sketch -> include library -> Morse
and "#include<Morse.h>" shows up in IDE, so at least that's recognized. but when i try to do anything, it says:
In file included from sketch_apr16a.ino:1:0:
C:\Users\ben\Documents\Arduino\libraries\Morse/Morse.h:1:19: fatal error: iostream: No such file or directory
#include
^
compilation terminated.
Error compiling.
bmarconi:
and then i went to sketch -> include library -> Morseand "#include<Morse.h>" shows up in IDE, so at least that's recognized. but when i try to do anything, it says:
The problem i believe is in your library code...
Topic: #include not working in custom library: #include <iostream> not working in custom library - Programming Questions - Arduino Forum
Every detail about a library installation is here: http://arduino.cc/en/guide/libraries#toc5
so i created a folder in my arduino sketch folder and put the files there. is this right?
No. Your library folder should be in the libraries folder in your sketches folder.
No. Your library folder should be in the libraries folder in your sketches folder.
that's what i meant oops
okay, here is everything
Morse.h:
#include<iostream>
#include<stream>
using namespace std;
class code
{
private:
string morse[28];
public:
string getmorse(int);
};
Morse.cpp:
#include "Morse.h"
#include<iostream>
#include<string>
#include "Arduino.h"
using namespace std;
string code::getmorse(int j)
{
string morse[28];
morse[0] = " "; //SPACE
morse[1] = ".- "; //A
morse[2] = "-... "; //B
morse[3] = "-.-. "; //C
morse[4] = "-.. "; //D
morse[5] = ". "; //E
morse[6] = "..-. "; //F
morse[7] = "--. "; //G
morse[8] = ".... "; //H
morse[9] = ".. "; //I
morse[10] = ".--- "; //J
morse[11] = "-.- "; //K
morse[12] = ".-.. "; //L
morse[13] = "-- "; //M
morse[14] = "-. "; //N
morse[15] = "--- "; //O
morse[16] = ".--. "; //P
morse[17] = "--.- "; //Q
morse[18] = ".-. "; //R
morse[19] = "... "; //S
morse[20] = "- "; //T
morse[21] = "..- "; //U
morse[22] = "...- "; //V
morse[23] = ".-- "; //W
morse[24] = "-..- "; //X
morse[25] = "-.-- "; //Y
morse[26] = "--.. "; //Z
morse[27] = "\0"; //NULL
return morse[j];
}
file location: documents/arduino/libraries/morse
error: .. same error with iostream. i read the post but i still don't understand what is to be done. I tried adding the solutino for other post but didn't work
I created a Morse folder in my sketches libraries folder and files containing your code named Morse.h and Morse.cpp in that folder. Stopped and started the IDE and was able to do Sketch/Import Library which added the
#include <Morse.h>line to my program. Verifying the program gave the following errors
Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Uno"
In file included from sketch_apr16a.ino:1:
C:\Users\Bob\Documents\Arduino\libraries\Morse/Morse.h:10: error: 'string' does not name a type
C:\Users\Bob\Documents\Arduino\libraries\Morse/Morse.h:13: error: 'string' does not name a type
so the compiler obviously found and used the Morse.h file
Now you need to fix the incorrect references to strings and the #includes with the wrong filenames in both of them.
#include "Morse.h"
#include<iostream>
#include<string>
#include "Arduino.h"
Spacesareagoodidea.
Something is wrong with your code in Morse.h
#include takes filename, the full filename, with correct case.
use <> for including libraries from sketchs / other libraries, use "" when including a .h
file in the same directory (such as your own library's .h file from its .cpp file.
Now you need to fix the incorrect references to strings and the #includes with the wrong filenames in both of them.
i realize i'm kinda being spoon fed everything but i have very little formal training in software. where do i find iostream and string / string.h? i searched my visualstudio directory but nothing showed up. and after i find them, do i just put the entire filepath in the "<>"?
VisualStudio is a foreign land for me but I would have thought that you would at least have needed to put the .h extension on the filenames in the #include.