先把串口接收代码烧入UNO单片机: 代码中大概功能是,循环接收串口信号,然后根据接收到的信号数值转动舵机角度
#include <Servo.h>String angle = "";Servo myse;void setup(){myse.attach(7); //设置舵机口myse.write(0); //初始化舵机角度Serial.begin(9600);}void loop(){while (Serial.available() > 0) {angle += char(Serial.read());delay(2);}if (angle.length() > 0){if (angle.toInt()<=360){myse.write(angle.toInt());}Serial.println(angle);angle = "";}}
然后UNO接上HC-05
接法:
STATE=NONE
RX=1
TX=0
GND=GND
+5V=5V
EN=3.3V
接法学自:/zx3517288/article/details/52291027
Android手机端App下载地址:
链接:/s/1n88J_42QKrPO3QQLJ0Qkyw
提取码:qjmo
Android手机端App源代码下载地址:
/download/hbmmcisn/12347721