Deactivate and reactivate the serial communication

Hello everyone,
I'm making a thermometer with an arduino uno but i have a problem with the serial monitor.
I am printing a lot of stuff with the function Serial.println(). I want to be able to stop all my Serial.println() functions an reactivate it later, with a I saw that it's possible to do it with the function Serial.end() which works in my case but later when i want to reactivate the Serial.println() using Serial.begin(9600) doesn't reactivate the Serial.println() functions that i set up in the loop.
So the problem is: how do i deactivate and reactivate the serial communication?
I hope that what i'm saying is clear :sweat_smile:

Declare a global boolean variable named printEnabled and set it to true

Make all of of your Serial.print()s conditional on the value of the boolean

if (printEnabled)
  Serial.print("whatever you want to print");

At the start of loop(), if Serial data is available, then read a character and if it is a '1' set printEnabled to true. If it is '0' set printEnabled to false

Thx for that fast and clear answer

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