Is there any way to stop/suspend the sketch execution?
It is quite annoying and confusing to see a storm of message strings filling the serial monitor or various leds blinkng while you are editing an already working program.
My only solution is to detach the usb cable from the board...quite stupid I think.
Keep a second instance of the IDE open with the BareMinimum sketch loaded and upload that to stop the currently running sketch. It only takes a matter of seconds to compile and upload
I like to set a pin and read that pin in a separate function, and if that pin is in one state, the function holds the program execution inside it until the pin is reset, releasing the program to continue...
void simulate()
{
if (SIMULATOR)
{
pinMode(A0, INPUT);
while (!analogRead(A0)); // While A0 is HIGH, do not release from this loop
}
}
I short reset to ground
You can close serial monitor ![]()
Without knowing your sketch, one thing to consider is to only generate output when something changes, e.g. when an input goes from HIGH to LOW instead of being LOW. But maybe you're doing that already.
I have no solution for blinking LEDs except for disconnecting them; but see @xfpd's reply.
Do less of Serial.print?
Use a timer function like millis() and print at a rate You want.
Is there any code that's printing like that?............
#firstworldprogrammerproblems
![]()
Yes, I see that this is the only viable solution even if honestly I would not wish to insert and configure this function in every sketch I'm testing. Anyway the real problem is not with the Serial, but with all the configurated I/O (leds and other stuff) that always run for nothing... so I will detach the USB.
It would be nice to have an ON/OFF power switch on the USB cable.
Thanks
This is interesting...I'll see, thanks
Personally I just do what I suggested in reply #2
This is the best solution. A simple CTRL-U and no more blinking. No extra hardware or functions.
Could you put a toggle switch between reset and 0v to hold the chip in reset, thereby stopping execution.
Alternatively, just tie low a digital with a jumper, pinmode it to INPUT_PULLUP, and at the start of loop(), drop in:
while(!digitalRead(haltpin)) {};
Lift the jumper when you want to run.
Not tested, so YMMV.
Stick a delay() in your sketch. You will know execution has reached that point in the code and you can slow the output.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.