3Motor::Motor(uint8_t pin, ledc_timer_t timer, ledc_channel_t channel){
11 pinMode(this->
pin,OUTPUT);
12 ledc_channel_config_t channelConfig = {
13 .gpio_num = this->
pin,
16 .intr_type = LEDC_INTR_DISABLE,
17 .timer_sel = this->
timer,
21 ledc_channel_config(&channelConfig);
22 Serial.println(
"Motor begin done");
29 for(
int i = 0;i<difference;i+=difference/20){
30 this->duty += difference/20;
36 for(
int i = 0;i>difference;i-=abs(difference/20)){
37 this->duty -= abs(difference/20);
This component controls the ability to rotate and change position.
uint16_t getSpeed(void)
returns the currently activ speed
Motor(uint8_t pin, ledc_timer_t timer, ledc_channel_t channel)
void begin(void)
Initializes the motor.
void setSpeed(uint16_t duty)
Set the Speed by changing the pwm. To avoid current peaks, a linear ramp-up is used.