Need Assistance With Stopwatch Program

Hi guys,

I downloaded this sketch from the net and am trying to get it working on my UNO.

I get the following errors:

sketch_oct07a.ino:17:10: error: invalid suffix “f00” on integer constant
sketch_oct07a.ino: In function ‘void loop()’:
sketch_oct07a:67: error: ‘buf’ was not declared in this scope
sketch_oct07a:115: error: ‘buf’ was not declared in this scope

Can someone please take a look at the attached sketch and try to work out what is going wrong?
All I have modified is the Digital Pins 7 & 8 (Used to be pins 1 & 2), and the #Include “StopWatch.h” (Used to be <StopWatch.h>).

I am still learning how to do things and combing through the Reference and learning pages on the Arduino site. I certainly have a lot more grey hairs now.

I have seen ‘buf’ used in other sketches and it works well but I have never seen ‘buf’ as ‘15F00’. What The???

Any help I can get with this sketch is greatly appreciated.

Cheers,

Sugar

sketch_oct07a.ino (5.3 KB)

Hi, is there meant to be a stop watch header file in this?
For StopWatch.h

Being new to Arduino, I’m not too sure what you mean.

I realised I needed to add the StopWatch Library to my system and followed the instructions to create .h and .ccp within a StopWatch directory.

I was having all sorts of trouble with the sketch not finding it till I came across a snippet that stated that I had to change the <> to “”

Cheers,

Sugar

I realised I needed to add the StopWatch Library to my system and followed the instructions to create .h and .ccp within a StopWatch directory.

But, you're not going to tell us where you got them? Or why you are creating a ccp file instead of a cpp file?

Sorry, I meant CPP.

I found the info at Arduino Playground - StopWatchClass

char buf[15f00];                       // string buffer for itoa function

So how many elements in 15f00 supposed to be? I don't understand that, and, not surprisingly, the compiler doesn't either.

Since that caused the compiler heartburn, buf is not defined, so the other error message make sense.

Weird, I wonder whether you have both the CPP file and header file in the same directory of your ino file? I tried it just now by copying and pasting the code from the site, and it seems to compile fine for me. I attached it as well :slight_smile:

Stopwatch2_0.zip (1.85 KB)

OK so I think I must have mucked up the Library installation.

Time to re-read and repair whatever I haven't done correctly.

I had to manually load the .h and .cpp files as there wasn't a zipped version that I could find.

Thanks for the help.

Cheers,

Sugar

OK so I think I must have mucked up the Library installation.

The error messages you are getting having nothing to do with the library. I don't see why you think the library is to blame for the errors in your sketch. It isn't.

PaulS:

OK so I think I must have mucked up the Library installation.

The error messages you are getting having nothing to do with the library. I don't see why you think the library is to blame for the errors in your sketch. It isn't.

As you can probably figure out, I am quite new to Arduino and how to program it. I came here seeking assistance to figure out what is going wrong with the sketch I found on the net, that will perform a stopwatch function with 2 buttons, one for start and one for stop.

Trustnoone has run this code and stated that it worked fine for him then all I can assume is that there is something wrong at my end and the only differences would possibly be the way I installed the StopWatch.h and StopWatch.cpp files.

If you have any ideas as to another cause of these errors, please let me know.

Here is the link to where I found the original code Arduino Based Auto Timer / Stop Watch Timer for Stroking Time Measurement : 6 Steps (with Pictures) - Instructables

Sugar

Sugar:
If you have any ideas as to another cause of these errors, please let me know.

PaulS has already pointed out the typo in your definition of char buf[15f00] which caused the four errors you were asking about.

PeterH:

Sugar:
If you have any ideas as to another cause of these errors, please let me know.

PaulS has already pointed out the typo in your definition of char buf[15f00] which caused the four errors you were asking about.

Please excuse my ignorance, I don't have the experience to decypher what the error is and what it should be.

Sugar

Let this be an opportunity to learn. NEVER trust an instructables. Every single one linked to in this forum has one error or another that renders the code unusable.

The array buf is used to hold an int converted to an ASCII string, in base 10. Since the longest string will result from converting -32768 to a string, and that string has 6 characters and a trailing NULL, a size for the array of 15 is sufficient. Get rid of the "foo" in that string.

And, tell instructables what you think of their fucking this one up, too.

Haha I can’t believe I missed that, it actually says foo!! lol.
Don’t let it get you down man, happens all the time, this instructables specifically seems like its trying to trick you, its missing quite a bit of stuff, and the coding leaves a lot be desired, and thats coming from me haha.

I just tried by adding the Stopwatch.h and .cpp files
changing the main of the code to
#include “StopWatch.h”
instead of
#include <StopWatch.h>

and removing the foo.
And compiles for me with that code. Although I can’t test anything since I have a due and it doesn’t seem to like the itoa function

Although I can't test anything since I have a due and it doesn't seem to like the itoa function

If you haven't tested, how do you know that the DUE and the itoa() function are not friends? What the hell does that mean, anyway?

PaulS:

Although I can’t test anything since I have a due and it doesn’t seem to like the itoa function

If you haven’t tested, how do you know that the DUE and the itoa() function are not friends? What the hell does that mean, anyway?

My apologies, what I meant when i said I can’t test anything, was that, I didn’t pull out my switches or LCD screen or even do a thorough check of the code to make sure it would work as intended due to the error I obtained trying it on the Due board.
I did however try to verify the code using the Arduino program which worked fine for me if the Uno board is checked but not if the Due board is checked.
Further research has lead me to believe that there is a library problem which makes things more difficult to use the itoa() function the same as compared to the Uno board.
I haven’t checked into it fully though, and honestly its not something I really care about since I don’t see myself using it for some time.
But I will make sure to do better next time in providing help on the forums in case it further confuses people.
Thanks

Further research has lead me to believe that there is a library problem which makes things more difficult to use the itoa() function the same as compared to the Uno board.

Fancy footwork, but seeing the actual errors messages is still necessary. It isn't even clear which library you think has a problem.

Edit: I downloaded the StopWatch library, and tried to compile the (corrected) instructables code using 1.5.2, for the Due, and it fails. Interestingly, C Programming/stdlib.h/itoa - Wikibooks, open books for an open world says that itoa() is a non-standard function that compiler writers often include, but are not required. Apparently, the function is not available for the Due. Strange.