Labview和Arduino通过串口点亮LED灯
作者:互联网
- Arduino程序
实现功能:发送ON点亮LED灯,发送OFF关闭LED灯
int LED = 13;
String buff="";
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT);
}
void loop() {
while(Serial.available()>0)
{
buff = buff + char(Serial.read());
delay(3);
}
if (buff=="ON")
{
digitalWrite(LED,HIGH);
Serial.println("LED IS ON");
buff="";
}
else if (buff=="OFF")
{
digitalWrite(LED,LOW);
Serial.println("LED IS OFF");
buff="";
}
delay(50);
}
-
Labview程序
在读取之后加了延时是为了解决串口读取时出现的假死现象
-
硬件实物图
标签:OFF,Arduino,串口,LED,Serial,buff 来源: https://blog.csdn.net/A1042236172/article/details/122724817