-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservo_control.cpp
More file actions
28 lines (22 loc) · 778 Bytes
/
servo_control.cpp
File metadata and controls
28 lines (22 loc) · 778 Bytes
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
#include "servo_control.h"
uint8_t chanel_v=7;
uint8_t chanel_h=8;
void setup_servo(){
Serial.println("setup_servo_pin");
setup_servo_pin(SERVO_V_PIN,chanel_v); //keep servo on previous position
setup_servo_pin(SERVO_H_PIN,chanel_h);
}
void setup_servo_pin(uint8_t pin, uint8_t chanel)
{
ledcSetup(chanel, SERVO_FREQ, SERVO_BITS); // channel , 50 Hz,
ledcAttachPin(pin, chanel); // GPIO assigned to channel
// ledcWrite(chanel, CALC_SERVO_PULSE(90)); //start from the middle //keep servo on previous position
}
void set_servo_v(uint8_t val){
Serial.println("set_servo_v");
ledcWrite(chanel_v, CALC_SERVO_PULSE(val));
}
void set_servo_h(uint8_t val){
Serial.println("set_servo_h");
ledcWrite(chanel_h, CALC_SERVO_PULSE(val));
}