Forum Etiquette

I'm looking for help trouble shooting a somewhat complex sketch found here,

based on a project found here,

and I think it is too big to upload as code in this forum.

Is it improper to use links to and ? If not, I would greatly appreciate some help advice solving a timing error in the code.

It is improper, only if you can't upload it as an attachment. Well, actually not improper, just futile as many people will dismiss it. An attachment is the usual and quite welcome solution.

But actually in my case, you had me at, "instructables" but we'll see... the quality of software there is generally so low, that it is a waste of time to try to fix it, or anything based on it.

Oh, and... please explain in detail what the problem is. "a timing error" doesn't get enough across...

One more thing. A huge effort has been expended to make it quite clear what the forum protocols are. Details are posted in the permanent threads at the top of the forum. You should probably read them.

Couldn't see anything at the tinkercad link as I don't have an account.

Is it the same source code as found here:

and if so, what's the problem?

I looked at the "instructions" . Very typical for motivationaldestructable

describing the programming-process that short

To program the Arduino: Download the Arduino IDE to your laptop. Upload the code to the Arduino with a usb cable. Source is here: the time units is 100ths of second and the time resolution < 10ms approx.

leaves newbees in despair

I downloaded the code from the Github-link mentioned in the "6-step-manual" and it compiles.

anyway: there is no way around describing what your problems are.

best regards Stefan

I'll try to clean up the code and eliminate the other optional sequences to see if I can get it under the 9000 character limit.

Why? Just add it as an attachment. Not to dissuade you from "cleaning it up"...

Here is the sketch as an attachment

That is only a 7k program so it should be quite possible to include it in your next Reply so we don’t have to download it.

Please also tell us in detail what it actually does and what you want it to do that is different. That way we can focus on the parts you need help with rather than wasting time on things that you can do.


Your explanation of the sequence of events has gone right over my head

As I understand it, the system sits idle then when the left button is pressed (why not give it a sensible name ?) a sequence starts. If that is correct then please list the sounds required (horn or buzzer) and at what intervals they are required and how long they should sound. I can't help feeling that you have made things more complicated than they need to be but cannot be sure

                           5 * 60000 + 6000, 5 * 60000 + 7000, 5 * 60000 + 8000, 5 * 60000 + 9000, 5 * 60000 + 10000, 

I think you need

                           5 * 60000L + 6000, 5 * 60000L + 7000, 5 * 60000L + 8000, 5 * 60000L + 9000, 5 * 60000L + 10000, 

This compiler warning might point to a problem that can screw up your timing:

/Users/john/Downloads/sketch_oct21b/sketch_oct21b.ino: In function 'void horn_or_beep(long int)':
/Users/john/Downloads/sketch_oct21b/sketch_oct21b.ino:138:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if ( s < v + 1000)                  // trigger activate_sound

ALWAYS use “CurrentTime - PreviousTime compared to Interval”. By subtracting the previous time from the current time you always get a positive value in your UNSIGNED result. If you ever get a NEGATIVE value in an UNSIGNED result it will be treated as a huge positive value.

I think you want:

     if ( s  - v < 1000)                  // trigger activate_sound

If you did not get this warning, go into Preferences and set “Compiler warnings:” to “All”.

If you require further feedback, please respond to reply #5 and #6.