Arduino - 串行绘图仪

news2024/9/20 0:53:01

Arduino - Serial Plotter Arduino - 串行绘图仪

In this tutorial, we will learn how to use the Serial Plotter on Arduino IDE, how to plot the multiple graphs.
在本教程中,我们将学习如何在Arduino IDE上使用串行绘图仪,如何绘制多个图形。

About Serial Plotter 关于串行绘图仪

Serial Plotter is one of the tools in Arduino IDE. Arduino can read the temperature, humidity or any kind of sensor data, and send it to Serial Plotter. Serial Plotter receives data from Arduino and visualizes data as waveforms. Serial Plotter can visualize not only single but also multiple sensor data in the same graph.
串行绘图仪是Arduino IDE中的工具之一。Arduino可以读取温度,湿度或任何类型的传感器数据,并将其发送到串行绘图仪。串行绘图仪从Arduino接收数据,并将数据可视化为波形。串行绘图仪不仅可以在同一图形中显示单个传感器数据,还可以显示多个传感器数据。

Data is exchanged between Serial Plotter and Arduino via USB cable, which is also used to upload the code to Arduino. Therefore, To use Serial Plotter, we MUST connect Arduino and PC via this cable.
数据通过USB线在串行绘图仪和Arduino之间交换,USB线也用于将代码上传到Arduino。因此,要使用串行绘图仪,我们必须通过此电缆连接Arduino和PC。

Serial Plotter includes a selection box to select the serial baud rate and a graph:
串行绘图仪包括一个选择框,用于选择串行波特率和一个图表:

  • X-axis: represent the time. It has 500 points. The time between each point is the time between two consecutive Serial.println() function calls. This time is usually equal to the time of loop() function.
    X轴:表示时间。它有 500 点。每个点之间的时间是两个连续的 Serial.println() 函数调用之间的时间。这个时间通常等于 loop() 函数的时间。
  • Y-axis: represents the values received from Arduino. The Y-axis automatically adjusts itself as the value increases or decreases.
    Y轴:表示从Arduino接收的值。Y 轴会随着值的增加或减少而自动调整。

If you want to use the Serial Plotter on your smartphone, you can use the Web Serial Plotter instead.
如果您想在智能手机上使用串行绘图仪,您可以改用网络串行绘图仪。

How To Open Serial Plotter 如何打开串行绘图仪

On Arduino IDE, Click Serial Plotter icon
在 Arduino IDE 上,单击 Serial Plotter 图标
请添加图片描述

Plotting of Single Line in Graph 图中单线的绘制

To print a single graph, we just need to send the data and terminate it by “\r\n” character.
要打印单个图形,我们只需要发送数据并用“\r\n”字符终止它。

In detail, we just need to useSerial.println() function
详细来说,我们只需要使用 Serial.println() 函数

Serial.println(variable); 

※ NOTE THAT: ※ 注意事项:

Serial.println() automatically appends “\r\n” characters after data.
Serial.println() 自动在数据后附加“\r\n”字符。

Example Code 示例代码

This example reads the value from an analog input pin and plots them on Serial Plotter
本例从模拟输入引脚读取值,并将其绘制在串行绘图仪上

/*

 * Created by ArduinoGetStarted.com
   *
 * This example code is in the public domain
   *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-plotter
   */

void setup() {
  Serial.begin(9600); //好像115200不行
}

void loop() {
  int y1 = analogRead(A0);

  Serial.println(y1);

  delay(100);
}
Quick Steps 快速步骤
  • Copy the above code and open with Arduino IDE
    复制上面的代码并使用Arduino IDE打开
  • Click Upload button on Arduino IDE to upload code to Arduino
    单击Arduino IDE上的“上传”按钮,将代码上传到Arduino
  • Open Serial Plotter 开放式串行绘图仪
  • Select baurate 9600 选择金黄色 9600
  • See graph on Serial Plotter
    参见串行绘图仪上的图表

请添加图片描述

Plotting of Multiple Lines in Graph 在图形中绘制多条线

When we want to plot multiple variables, we need to separate variables from each other by “\t” or " " character. The last value MUST be terminated by “\r\n” characters.
当我们想绘制多个变量时,我们需要用"\t"或" "字符将变量彼此分开。最后一个值必须以“\r\n”字符结尾。

In detail: 详细地:

  • The first variable 第一个变量
Serial.print(variable_first); 
  • The middle variables 中间变量
Serial.print("\t"); // or Serial.print(" ")
Serial.print(variable_nth); 
  • The last variable 最后一个变量
Serial.print("\t"); // or Serial.print(" ") 
Serial.println(variable_last); 

Example Code 示例代码

This example reads the value from 4 analog input pins and plots them on Serial Plotter
本例从4个模拟输入引脚读取值,并在串行绘图仪上绘制

/*

 * Created by ArduinoGetStarted.com
   *
 * This example code is in the public domain
   *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-plotter
   */

void setup() {
  Serial.begin(9600); 
}

void loop() {
  int y1 = analogRead(A0);
  int y2 = analogRead(A1);
  int y3 = analogRead(A2);
  int y4 = analogRead(A3);

  Serial.print(y1);
  Serial.print(" "); // a space ' ' or  tab '\t' character is printed between the two values.
  Serial.print(y2);
  Serial.print(" "); // a space ' ' or  tab '\t' character is printed between the two values.
  Serial.print(y3);
  Serial.print(" "); // a space ' ' or  tab '\t' character is printed between the two values.
  Serial.println(y4); // the last value is followed by a carriage return and a newline characters.

  delay(100);
}

Multiple Graph: 多图:

请添加图片描述

Example of 3 Sine Waveforms 3 正弦波形示例

/*

 * Created by ArduinoGetStarted.com
   *
 * This example code is in the public domain
   *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-plotter
   */

void setup() {
  Serial.begin(9600);
}

void loop() {
  for(int i = 0; i < 360; i += 5) {
    float y1 = 1 * sin(i * M_PI / 180);
    float y2 = 2 * sin((i + 90)* M_PI / 180);
    float y3 = 5 * sin((i + 180)* M_PI / 180);

​    Serial.print(y1);
​    Serial.print("\t"); // a space ' ' or  tab '\t' character is printed between the two values.
​    Serial.print(y2);
​    Serial.print("\t"); // a space ' ' or  tab '\t' character is printed between the two values.
​    Serial.println(y3); // the last value is followed by a carriage return and a newline characters.

​    delay(100);
  }
}

Multiple Sine Waveform Graph:
多正弦波形图:

请添加图片描述

Video Tutorial 视频教程

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.
我们正在考虑制作视频教程。如果您认为视频教程是必不可少的,请订阅我们的 YouTube 频道,为我们制作视频提供动力。

Function References 函数参考

  • Serial.available()
  • Serial.begin()
  • Serial.print()
  • Serial.println()
  • Serial.read()
  • Serial.readBytes()
  • Serial.readBytesUntil()
  • Serial.readString()
  • Serial.readStringUntil()
  • Serial.write()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1860131.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【软件工程】【22.04】p2

关键字&#xff1a; 软件开发分本质及涉及问题、需求规约与项目需求不同、用况图概念包含模型元素及其关系、创建系统的用况模型RUP进行活动、软件生存周期&软件生存周期模型&软件项目过程管理关系、CMMI基本思想 模块结构图&#xff1a;作用域、控制域&#xff1b;语…

vue2 antd 开关和首页门户样式,表格合计

1.首页门户样式 如图 1.关于圆圈颜色随机设置 <a-col :span"6" v-for"(item, index) in menuList" :key"index"><divclass"circle":style"{ borderColor: randomBorderColor() }"click"toMeRouter(item)&qu…

版本控制工具-git分支管理

目录 前言一、git分支管理基本命令1.1 基本命令2.1 实例 二、git分支合并冲突解决三、git merge命令与git rebase命令对比 前言 本篇文章介绍git分支管理的基本命令&#xff0c;并说明如何解决git分支合并冲突&#xff0c;最后说明git merge命令与git rebase命令的区别。 一、…

Python重拾

1.Python标识符规则 字母&#xff0c;下划线&#xff0c;数字&#xff1b;数字不开头&#xff1b;大小写区分&#xff1b;不能用保留字&#xff08;关键字&#xff09; 2.保留字有哪些 import keyword print(keyword.kwlist)[False, None, True, and,as, assert, async, await…

【AI兼职副业必看,行业分析+注意事项+具体应用,想要做点副业的小白必看!】

前言 随着AI技术的日新月异&#xff0c;它已悄然渗透到我们生活的每一个角落&#xff0c;成为了我们日常生活和工作中的得力助手。在当前经济下行的环境下&#xff0c;AI技术更是成为了提升工作效率、拓展业务领域的关键。对于我们普通人而言&#xff0c;有效利用AI工具&#…

应变计在工程中的角色:精准监测与安全保障的得力助手

在工程领域中&#xff0c;应变计作为一种重要的测量工具&#xff0c;扮演着精准监测与安全保障的得力助手的角色。它能够实时、准确地测量物体在受力作用下的变形情况&#xff0c;为工程师提供关键的数据支持&#xff0c;从而确保工程的稳定性与安全性。 应变计在工程中的应用范…

深度学习训练基于Pod和RDMA

目录 ​编辑 引言 RDMA技术概述 InfiniBand iWARP RoCE Pod和容器化环境 深度学习训练与RDMA结合 MPI和RDMA 深度学习框架与RDMA 实战&#xff1a;基于Pod和RDMA的深度学习训练 环境准备 步骤 YAML 性能和优势 结论 引言 随着深度学习在人工智能领域的快速发展…

2024数字孪生发展研究报告

来源&#xff1a;华为&ampamp中国信通院 近期历史回顾&#xff1a; 2023内蒙古畜牧业温室气体减排策略与路径研究报告-能源基金会.pdf 2023园区工商业配储项目储能系统技术方案.pdf 欧洲和美国储能市场盘点&#xff08;英文&#xff09;.pdf 2024年第1季度全球ESG监管政策…

Python爬取中国福彩网彩票数据并以图表形式显示

网页分析 首先打开中国福彩网&#xff0c;点击双色球&#xff0c;选择往期开奖栏目 进入栏目后&#xff0c;选定往期的奖金数目作为我们想要爬取的目标内容 明确目标后&#xff0c;开始寻找数据所在的位置 鼠标右击页面&#xff0c;打开网页源代码&#xff0c;在源代码中搜索…

B端系统:消息页面的设计要点

在B端系统中&#xff0c;消息页面的作用是为用户提供实时的通信和信息交流功能&#xff0c;以便用户能够及时获取和处理重要的业务消息和通知。设计一个好的消息页面可以提高用户的工作效率和沟通效果。 以下是一些建议来设计消息页面&#xff1a; 易于查看和管理&#xff1a;…

免费直播课程!6月30日

<面向人工智能领域的开发工程师&#xff0c;特别是机器学习/深度学习方向> 在这里报名听课&#xff1a; F学社-全球FPGA技术提升平台 (zzfpga.com) TIPS&#xff1a; 报名后将在页面内弹出「腾讯会议号和会议密码」&#xff0c;注意复制保存哦~

备考必备:NOC大赛2022图形化编程决赛真题与解析

为了大家备考2023-2024学年全国中小学信息技术创新与实践大赛&#xff08;NOC大赛&#xff09;&#xff0c;角逐恩欧希教育信息化发明创新奖&#xff0c;今天给大家分享2022年NOC大赛图形化编程决赛真题试卷。 下载&#xff1a;更多NOC大赛真题及其他资料在网盘-真题文件夹或者…

Java高级重点知识点-10-Object类

文章目录 Object类(java.lang) Object类(java.lang) Object类是Java语言中的根类&#xff0c;即所有类的父类 重点&#xff1a; public String toString()&#xff1a;返回该对象的字符串表示。 public class User {private String username;private String password;public…

JavaWeb系列十三: 服务器端渲染技术(JSP) 下

韩顺平 2. EL表达式2.1 EL表达式快速入门2.2 EL表达式输出形式2.3 el运算符2.4 empty运算2.5 EL获取四个域数据2.6 EL获取HTTP相关信息 3. JSTL标签库3.1 jstl 快速入门3.2 <c:set/>标签3.3 <c:if/>标签3.4 <c:choose/>标签3.5 <c:forEach/>标签3.6 作…

蓝牙技术|苹果iOS 18的第三方配件将支持AirPods / AirTag的配对体验

苹果公司在 iOS 18 系统中引入了名为 AccessorySetupKit 的新 API&#xff0c;用户不需要进入蓝牙设置和按下按钮&#xff0c;系统就能识别附近的配件&#xff0c;并提示用户进行配对。首次向配件制造商开放这种配对体验。 iPhone 用户升级 iOS 18、iPad 用户升级到 iPadOS 1…

SAP BC 修改 FINS_ACDOC_CUST116 ERROR 为 WARNING 信息

FI再改如下配置时报错了 消息号 FINS_ACDOC_CUST116 参考 SAP 消息控制_sap消息号更改w为e-CSDN博客 需要指出的是你必须注意做重要的三个表 T100:包含所有的message T100C:你定义的message通常将出现在此表 T100s:Configurable system messages顾名思义就是你能设置的消息…

游戏AI的创造思路-技术基础-深度学习(4)

下面的内容是让AI进行左右互博&#xff0c;这就是传说中的GAN对抗网络 当然&#xff0c;周伯通和GAN真的是难兄难弟&#xff0c;欲练神功&#xff0c;结果被黄药师&#xff08;欺骗&#xff09;坑了 目录 3.4. 生成对抗网络&#xff08;GAN&#xff09; 3.4.1. 定义 3.4.2.…

JVM专题四:JVM的类加载机制

Java中类的加载阶段 类加载 Java中的类加载机制是Java运行时环境的一部分&#xff0c;确保Java类可以被JVM&#xff08;Java虚拟机&#xff09;正确地加载和执行。类加载机制主要分为以下几个阶段&#xff1a; 加载&#xff08;Loading&#xff09;&#xff1a;这个阶段&#x…

ServBay[中文] 下一代Web开发环境

ServBay是一个集成式、图形化的本地化Web开发环境。开发者通过ServBay几分钟就能部署一个本地化的开发环境。解决了Web开发者&#xff08;比如PHP、Nodejs&#xff09;、测试工程师、小型团队安装和维护开发测试环境的问题&#xff0c;同时可以快速的进行环境的升级以及维护。S…

【源码+文档+调试讲解】校园商铺管理系统

摘 要 随着科学技术的飞速发展&#xff0c;各行各业都在努力与现代先进技术接轨&#xff0c;通过科技手段提高自身的优势&#xff1b;校园商铺当然也不能排除在外&#xff0c;随着网络技术的不断成熟&#xff0c;带动了校园商铺的发展&#xff0c;它彻底改变了过去传统的管理方…