初始化提交

This commit is contained in:
王立帮
2024-07-20 22:09:06 +08:00
commit c247dd07a6
6876 changed files with 2743096 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
#ifndef QDPservo2_h
#define QDPservo2_h
#include <Arduino.h>
class QDPservo2 {
public:
QDPservo2(uint8_t pin);
void goAngle(int angle);
private:
uint8_t _pin;
};
#endif

View File

@@ -0,0 +1,19 @@
#include "QDPservo2.h"
QDPservo2::QDPservo2(uint8_t pin) {
pinMode(pin, OUTPUT);
_pin = pin;
}
void QDPservo2::goAngle(int angle) {
int pulsewidth = (angle * 11) + 500; //将角度转化为500-2480的脉宽值
// for (int i = 0; i < 50; i++) {
digitalWrite(_pin, HIGH); //将舵机接口电平至高
delayMicroseconds(pulsewidth); //延时脉宽值的微秒数
digitalWrite(_pin, LOW); //将舵机接口电平至低
delayMicroseconds(20000 - pulsewidth);
// }
delay(100);
}