Arduino Serial Data Plotter | Let’s Start Coding | Coding for Kids
In this release, the coolest new feature has to be the “Serial Plotter” which takes in data from a sensor (like a light sensor, sound sensor, or temperature sensor) and graphs it on a moving line chart. Since this feature is new and you’ll definitely want to incorporate it into your projects, we want to share some info about how you can use it.
Mục lục bài viết
1) What’s this good for?
Microcontrollers like the Maker Board or Arduino Uno boards are good at gathering data from the real world, but they haven’t been able to display it simply and graphically like this before. The graphing feature of the Serial Plotter allows you to quickly see relative changes in your data without looking at a stream of number values or copying and pasting the data to Excel or Google Sheets.
2) When do I use it?
The Serial Plotter will work best for analog sensors. Those are the sensors that can report a range of values. Think about a light switch. It has only two values: on or off. Now think about a dimmer switch. It has a range of values, including off, on, 50% on, 23% on, and every value between 0 and 100%. Those types of sensors will be the most interesting to use with Serial Plotter.
3) How do I Write code for it?
If you’re familiar with the Serial Monitor, the Serial Plotter will be an easy next step for visualizing your readings.
First, you need to create a program that uses an analog sensor. This could be a light reading, a distance sensor, or a sound trigger. Once your component is ready in the void setup(){ } portion of your code, write:
Serial.begin(9600);
also in the void setup(){ } section of your code.
Then, in the loop of your code, type the Serial Print Line command:
Serial.println( Your reading or variable here) ;
That line will send the reading to the Serial Monitor / Serial Plotter.
Each time your code loops over the Serial.println( ) line, the newest reading is sent to the Serial Plotter.