Hello! I was wondering if it's possible to switch the data the Serial Monitor is reading. For example, lets say I had a soil moisture sensor printing on the serial monitor and got the data that triggers a tilt sensor and want the moisture sensor to stop sending its data. What would I do? Thanks, bassoon30.
At drag-slow baud rate of 9600, Serial still sends 960 chars/sec to Serial Monitor which for short prints will not have time for "correction" to apply. BUT at that speed or any speed you can easily overfill the 64-char Serial Output Buffer and then execution stalls down until enough chars get sent that what's left to print fits in the buffer. That is where 9600 baud HURTS the sketch way more than 115200 baud serial.
The program that you write would make decisions about which data to display on the serial monitor. For example, the program could read a button pin, which might cause it to select a different sensor to sample.
Or the program could read two sensors sequentially and report the individual data for each.
If I can speak to what I think @jremington said, the data you see on the serial monitor is a function of its inputs, such as sensors. The Arduino doesn't take Serial monitor data and apply it to the program (I mean it could I guess, but in your scenario, doing it that way would be an unreliable shortcut around the world), it displays for human convenience data that it receives electrically from whatever sensor you steer the program to.
In your program, every Serial.print( whatever you specify) will be sent to the serial monitor. The serial monitor is a "dumb" device that only displays what you send.
So you could:
- always print the moisture sensor AND the tilt sensor data (on the same line)
- have the program change what you specify to print when the serial monitor.
For more of a code example, you will have to be more specific as to your goal. For instance after the tilt sensor is triggered, the moisture data stops.... OK what is next?
I want the tilt sensor data to only print.
Thank you so much! I think my bug is fixed.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.