-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceDriverSet_xxx0_ServoControl.cpp
More file actions
43 lines (40 loc) · 1.03 KB
/
DeviceDriverSet_xxx0_ServoControl.cpp
File metadata and controls
43 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* @Author: ELEGOO
* @Date: 2019-10-22 11:59:09
* @LastEditTime: 2020-06-12 16:36:20
* @LastEditors: Changhua
* @Description: conqueror robot tank
* @FilePath:
*/
#include "DeviceDriverSet_xxx0_ServoControl.h"
#include <arduino.h>
/*Servo*/
Servo myservo; // create servo object to control a servo
void DeviceDriverSet_Servo::DeviceDriverSet_Servo_Init(unsigned int Position_angle)
{
myservo.attach(PIN_Servo_z, 500, 2400); //500: 0 degree 2400: 180 degree
myservo.attach(PIN_Servo_z);
myservo.write(Position_angle); //sets the servo position according to the 90(middle)
delay(500);
}
#if _Test_DeviceDriverSet
void DeviceDriverSet_Servo::DeviceDriverSet_Servo_Test(void)
{
for (;;)
{
myservo.attach(PIN_Servo_z);
myservo.write(180);
delay(500);
myservo.write(0);
delay(500);
}
}
#endif
/*0.17sec/60degree(4.8v)*/
void DeviceDriverSet_Servo::DeviceDriverSet_Servo_control(unsigned int Position_angle)
{
myservo.attach(PIN_Servo_z);
myservo.write(Position_angle);
delay(450);
myservo.detach();
}