Delays in Arduino sketch

Hello guys,

I'm trying to modificate an Arduino sketch, can you explain me these lines of code?
What is the delay for?

<while(softSerial.available()) softSerial.read();

nano.getVersion();

if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
{
//This happens if the baud rate is correct but the module is doing a ccontinuous read
nano.stopReading();

Serial.println(F("Module continuously reading. Asking it to stop..."));

delay(540000);

}
else
{
//The module did not respond so assume it's just been powered on and communicating at 115200bps
softSerial.begin(115200); //Start software serial at 115200

nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg

softSerial.begin(baudRate); //Start the software serial port, this time at user's chosen baud rate

}>

Thanks :slight_smile:

Welcome to the forum

Please post the complete sketch using code tags when you do

When you posted the code without code tags did you receive a warning message ?

Looks like whoever wrote the program wanted it to stop for 9 minutes for some reason.

No idea, you hove not posted any code that makes sense.

However, delay(540000); pauses the program for 9 minutes, not 8 minutes.

Hello,

When RFID tag is detected the sequence start but if the tag is detected again the sequence start again from zero.
How can I insert a pause after the first detection?

Thanks

Use the delay function call?

I tried but honestly I don't know where insert it, in the code at the end I used a delay(540000).
Is a good solution to block that while cycle?

What? Nine minutes delay, is that not a bit silly?

But you said

That is where it goes.

The runtime require about 7 minutes, I need a delay to stop the detection after the first and start again when I'm sure the runtime is finished

Why are you posting twice about what looks like the same problem?
This is against the forum rules and is known as cross posting.

Create a variable that stores the millis value of the last time a tag was found, then calculate the difference between the real time millis and that variable to see how long it has been since the last time a tag was found.

Check out this link, it might be helpful.

Debounce

Which is no difference at all from using a delay.

1 Like

TOPIC MERGED.

Could you take a few moments to Learn How To Use The Forum.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.