当前位置:网站首页>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、程序框图设计






边栏推荐
- Comprehensive RTL code design method and precautions
- Field queryIndexFieldnameService in xxxImpl required a single bean, but 19 were found:
- Part II data link layer
- JMeter load test finds the maximum number of concurrent users (including step analysis)
- JVM|运行时数据区;程序计数器(PC寄存器);
- RANSAC提取圆柱(MATLAB内置函数)
- Go language functions
- Goland中在文件模板中为go文件添加个人声明
- 如何使用 SAP Kyma 控制台手动发送 SAP Commerce Cloud Mock 应用暴露的事件
- 二分图King
猜你喜欢

Obsidian关系图谱如何让节点可以手动拖动
![[Part 15] use and basic principle of forkjoinpool [key]](/img/36/e21b16ec92d444149bc793f340f9f3.jpg)
[Part 15] use and basic principle of forkjoinpool [key]

Codeforces Round #744 (Div. 3) 解题报告

Cs144 lab0 lab1 record

What are striplines and microstrip lines? Reference planes and transmission lines

A collection of commonly used open source data sets for face recognition

Jenkins+allure integrated report construction

The official announced the launch of Alibaba's 2023 global school recruitment: Technical Posts account for more than 60%

How to Load Data from CSV (Data Preparation Part)

SQL的语法
随机推荐
字符串复制函数
Work assessment of spectral analysis of Jilin University in March of the 22nd spring -00079
常用文件函数
Educational Codeforces Round 114 (Rated for Div. 2) D
JVM object allocation policy TLAB
成长的12条黄金法则
[Part 16] copyonwritearraylist source code analysis and application details [key]
Go language for loop
Test plans and test cases
Diary at 16:29:41 on June 9, 2022
JVM|虚拟机栈(局部变量表;操作数栈;动态链接;方法的绑定机制;方法的调用;方法返回地址)
Educational Codeforces Round 111 (Rated for Div. 2) C 补题
JS performs non empty judgment on various data types of the returned data.
关于斜率优化
作为一名 ABAP 资深顾问,下一步可以选择哪一门 SAP 技术作为主攻方向?
apache 本地多端口配置
数据库每日一题---第9天:销售员
Why microservices are needed
Codeforces Round #744 (Div. 3) 解题报告
My collection of scientific research websites