C#制作简单上位机监控arduino
2019-08-31 12:15
(新修改的,所以跟视频的程序界面不一样)程序界面:
可实现监控arduino,LED亮变成蓝色,灭变成白色。
arduino代码:
//上下位机串口通讯int led = 6;//引脚定义
void setup() {pinMode(led, OUTPUT);//定义引脚输出 Serial.begin(9600, SERIAL_8N1);//通讯设置}
void loop() { int du;//存储接收的数据Serial.available();du = Serial.read();//接收if (du == 1) //等于1点亮led{while (1){digitalWrite(led, HIGH);Serial.print(digitalRead(led));//传送高低电平给上位delay(1000);//+++++++++++++++++++++++++++++++++++++++digitalWrite(led, LOW);Serial.print(digitalRead(led));delay(1000);du = Serial.read();//接收if(du==0){digitalWrite(led, LOW);Serial.print(digitalRead(led));break;}}}}
上位机和下位机源码:
https://gitee.com/TDZT/WS_C-Sharp/tree/master_1
--end--
声明:本文章由网友投稿作为教育分享用途,如有侵权原作者可通过邮件及时和我们联系删除:freemanzk@qq.com