当前位置:网站首页>LabVIEW控制Arduino实现红外测距(进阶篇—6)
LabVIEW控制Arduino实现红外测距(进阶篇—6)
2022-06-11 21:23:00 【InfoQ】
1、项目概述

2、项目架构

3、硬件环境

4、Arduino功能设计
#define Infrared_COMMAND 0x10 //采集命令字
byte comdata[3]={0}; //定义数组数据,存放串口接收数据
void receive_data(void); //接受串口数据
void test_do_data(void); //测试串口数据是否正确,并更新数据
float SensorSum = 0;
int SensorPin = A0; // select the input pin for the potentiometer
void setup()
{
Serial.begin(9600);
}
void loop()
{
while (Serial.available() > 0) //不断检测串口是否有数据
{
receive_data(); //接受串口数据
test_do_data(); //测试数据是否正确并更新标志位
}
}
void receive_data(void)
{
int i ;
for(i=0;i<3;i++)
{
comdata[i] =Serial.read();
//延时一会,让串口缓存准备好下一个字节,不延时可能会导致数据丢失,
delay(2);
}
}
void test_do_data(void)
{
if(comdata[0] == 0x55) //0x55和0xAA均为判断是否为有效命令
{
if(comdata[1] == 0xAA)
{
if(comdata[2] == Infrared_COMMAND)
{
for (int i = 0; i < 10; i++){
SensorSum += analogRead(SensorPin);
delay(5);
}
Serial.println(SensorSum*5.00/1023/10,2);
SensorSum=0;
}
}
}
}5、LabVIEW功能设计
5.1、前面板设计

5.2、程序框图设计






边栏推荐
- The official announced the launch of Alibaba's 2023 global school recruitment: Technical Posts account for more than 60%
- 正则校验匹配[0-100]、[0-1000]之间的正整数或小数点位数限制
- JMeter load test finds the maximum number of concurrent users (including step analysis)
- 一个Golang的私有库设置问题
- 一步步把 SAP UI5 应用部署到 SAP BTP Kyma 运行环境中去
- Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system
- apache 本地多端口配置
- Codeforces Round #739 (Div. 3)解题报告
- JVM|运行时数据区;程序计数器(PC寄存器);
- In idea, run the yarn command to show that the file cannot be loaded because running scripts is disabled on this system
猜你喜欢

Pyqt5 technical part - set the default value of qcombobox drop-down box and get the current selection of the drop-down box

关于斜率优化

数据库每日一题---第9天:销售员

第二部分 数据链路层

Cs144 lab0 lab1 record

JS performs non empty judgment on various data types of the returned data.

gateway先启动其他微服务,在启动网关,网关启动不了,且无异常日志;先启动网关,所有服务能正常启动

Online excel file parsing and conversion to JSON format

第一部分 物理层

js对返回的数据的各种数据类型进行非空判断。
随机推荐
JVM runtime constant pool and direct memory
第一部分 物理层
JVM|虚拟机栈(局部变量表;操作数栈;动态链接;方法的绑定机制;方法的调用;方法返回地址)
实现 TabLayout 下标与文字等长,选中字体大小改变
Field queryIndexFieldnameService in xxxImpl required a single bean, but 19 were found:
Tensorflow 2. X Getting Started tutorial
Which Bluetooth headset is better within 500? Inventory of gifts for girls' Day
Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system
Cs144 lab0 lab1 record
八、BOM - 章节课后练习题及答案
Why is your LDO output unstable?
Serval and Rooted Tree(CF1153D)-DP
数据库每日一题---第9天:销售员
LeetCode-98-验证二叉搜索树
JVM method area
【 C Advanced language】 Integer Storage in Memory
【博弈论-完全信息静态博弈】 战略式博弈
【生活思考】文字与语音
ASCII码对照表
How to import workflows provided on SAP API hub to sap BTP