一个arduino控制舵机的demo
一个arduino控制舵机的demo
模块:舵机 超声波 蓝牙
功能:当物体距离小于10cm时控制夹子夹住物体,并向外传输实测的距离。
程序:
#include <Servo.h>
int TrgPin = A0;
int EcoPin = A1;
int dist;
Servo myservo; // 定义Servo对象来控制
int pos = 0; // 角度存储变量
void setup() {
Serial.begin(9600);
myservo.attach(9);//
原创
2021-02-22 11:34:14 ·
889 阅读 ·
1 评论