Pages: [1]   Go Down
Author Topic: Newbie: Finding Libraries  (Read 1279 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

I'm very new to arduino, and c/c++.  I keep on running into the same problem.  I come upon some piece of code on the wiki or somewhere else, and try to use it, and alas, I'm missing many libraries.

For example, right now I'm trying to use StopWatch.  I downloaded StopWatch and gave it a directory in Libraries, and tried to use it (yes I got both .h and .cpp).

Of course, the following errors occured:

Code:
arduino-0022/libraries/StopWatch/StopWatch.cpp:16:21: error: Wstring.h: No such file or directory
arduino-0022/libraries/StopWatch/StopWatch.cpp:17:20: error: Wiring.h: No such file or directory
arduino-0022/libraries/StopWatch/StopWatch.cpp: In member function ‘void StopWatch::start()’:
arduino-0022/libraries/StopWatch/StopWatch.cpp:35: error: ‘millis’ was not declared in this scope
arduino-0022/libraries/StopWatch/StopWatch.cpp: In member function ‘long unsigned int StopWatch::value()’:
arduino-0022/libraries/StopWatch/StopWatch.cpp:43: error: ‘millis’ was not declared in this scope
arduino-0022/libraries/StopWatch/StopWatch.cpp: In member function ‘void StopWatch::stop()’:
arduino-0022/libraries/StopWatch/StopWatch.cpp:52: error: ‘millis’ was not declared in this scope

I'm losing tons of time searching to and fro trying to find things, normally with little success.  I end up with 30 tabs open, which is only helping me to lose my mind.  Is there something I'm missing, like some site or large file somewhere that contains all the commonly used libraries out there?

Throw me a bone here if you get the chance.  It would be much appreciated.

Thanks.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It shouldn't be that hard. You state: "gave it a directory in Libraries"

The libraries folder name in your Arduino sketch folder must not start a capital L?

Could your problem be that simple?

Lefty

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wouldn't think it would be that hard either, but it either is, or I am a terrible web searcher (def. possible).

Sorry about the capital L there, the path is in the code box there and the L is not capitalized so unfortunately that isn't my problem.

Thanks.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi there...i'm no expert...but that Stopwatch program isn't a library and doesn't appear to use any special libraries. You just copy the code, put it in the IDE and run it. When you save it just save it where you save all your arduino sketches. You are using this? http://www.arduino.cc/playground/Code/Stopwatch

here is where most good contributed libraries are: http://arduino.cc/en/Reference/Libraries

a lot of times sketches you find online are outdated or don't work...but anything on the arduino webpage will usually work just fine...
hope this helps...sorry if you know all this already...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I am trying to use the following: http://www.arduino.cc/playground/Code/StopWatchClass  It apparently uses Wstring.h and Wiring.h, for which I found a piece of code on code.google.com that then calls a bunch of other libraries I probably don't have, and with no .cpp to be found.

I have taken a look at the main libraries reference page on the Arduino site, and maybe some of the things I have been looking for are buried in some of those libraries.  I've been trying to look through them.

Edit: Ok, I found millis(). 1 small victory.
(For instance, there is a function millis() that a lot of code tends to utilize apparently, and every time I search for it like everything else I search for, I find links to it being used, but never the functions code or where I can get it.)

Thanks a bunch for trying to help me.

« Last Edit: February 27, 2011, 06:51:51 pm by fizzicks » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
For instance, there is a function millis() that a lot of code tends to utilize apparently, and every time I search for it like everything else I search for, I find links to it being used, but never the functions code or where I can get it.

millis() is a arduino build-in function that is in the arduiono cores folder and not stored in your users libraries folder. Here is a listing of my arduino core library files, millis() is a function defined in one of them. If you use a function that is listed in the official arduino reference page: http://arduino.cc/en/Reference/HomePage , It is not a function you have to load into your skectch, the arduino IDE automatically knows where to find it. Here is where all the build=in functions come from:

Wiring.h (and .c) contains the millis() function along with a lot of others.

Quote
C:\Documents and Settings\Primary Windows User\My Documents\My Programs\Arduino\arduino-0022\hardware\arduino\cores\arduino

0 Folders:

24 Files:

binary.h
HardwareSerial.cpp
HardwareSerial.h
main.cpp
pins_arduino.c
pins_arduino.h
Print.cpp
Print.h
Stream.h
Tone.cpp
WCharacter.h
WConstants.h
WInterrupts.c
wiring.c
wiring.h
wiring_analog.c
wiring_digital.c
wiring_private.h
wiring_pulse.c
wiring_shift.c
WMath.cpp
WProgram.h
WString.cpp
WString.h

There is also a folder for 'official arduino libraries' that come with each distrubution of the IDE:

Quote
C:\Documents and Settings\Primary Windows User\My Documents\My Programs\Arduino\arduino-0022\libraries

13 Folders:

ArduinoTestSuite
EEPROM
Ethernet
Firmata
LiquidCrystal
Matrix
SD
Servo
SoftwareSerial
SPI
Sprite
Stepper
Wire


0 Files:

And finally there is a place where you store library code for user contributed (that you might find on the web or in the arduino playground area) or ones you write yourself:

Quote
C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries

10 Folders:

Button
DS1307
Flash
MsTimer2
Playtune
Streaming
String
Tone
WString
__MACOSX


0 Files:

I know it can be a bit confusing but start simple and you should get the hang of it soon. When you are in the Arduion IDE there is a Sketch button/Import Library you can hit and it will show you the names of libraries avalible for you to include by selecting one. You will notice that the list comes in two sections, the top section is the official arduino libraries and the 'Contributed' list is from library folders you have stored in your users libraries folder.

That help?

Lefty


« Last Edit: February 27, 2011, 07:21:46 pm by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that definitely helps.  I had just realized that I had looked over milli() on the main reference page (I must be blind).  The first list with the built-in functions and libraries in the cores directory is very helpful, and good to know that that is where all the built in functions are located.

I think Linux/Arduino was just not able to locate them for some reason, and so I didn't think I had them especially because they weren't in the library directory.  My Sketch/Import library menu isn't segmented, but it is probably because I'm on Linux.

Sorry to bother, and thanks a bunch for the help.  Much appreciated.

Bill
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My Sketch/Import library menu isn't segmented, but it is probably because I'm on Linux.

Or possibly because you haven't created a user libraries folder correctly or in the correct directory, or you have never placed any library folders containing .h and .c or .cpp files? I don't think it's a windows/Linux thing at all. The IDE is just telling you it didn't find any user library files for whatever reason.


Lefty

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, yeah I never created a user libraries directory.  When I grabbed StopWatch.h and StopWatch.cpp I just created a new directory: arduino-0022/libraries/StopWatch and put the files in there.  I guess I was supposed to create a new user libraries directory?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, yeah I never created a user libraries directory.  When I grabbed StopWatch.h and StopWatch.cpp I just created a new directory: arduino-0022/libraries/StopWatch and put the files in there.  I guess I was supposed to create a new user libraries directory?

Correct. Unfortunately installing the Arduino IDE does not go ahead and create a user's library folder into the user's sketch folder. It probably should check if you have one or not and if not create such a directory. In older versions of the IDE there was no concept of a users library directory that the IDE would search for, instead you had to load any libraries you found into the arduino core libraries directory. That worked, but every time you upgraded to a new arduino IDE version you would end up losing all your contributed library files. No winning I guess, you just have to play the game.  smiley-grin
Logged

Pages: [1]   Go Up
Jump to: