[feature/ServoMotor] - change servo librarie
This commit is contained in:
32
lib/ServoMotorComponent/src/ServoMotorComponent.cpp
Normal file
32
lib/ServoMotorComponent/src/ServoMotorComponent.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "ServoMotorComponent.h"
|
||||
|
||||
ServoMotorComponent::ServoMotorComponent(int PIN) {
|
||||
this->PIN = PIN;
|
||||
this->position = 0;
|
||||
this->myservo.attach(PIN);
|
||||
}
|
||||
|
||||
void ServoMotorComponent::goLeft() {
|
||||
this->myservo.write(this->PIN, 0);
|
||||
this->position = 0;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::goRight() {
|
||||
this->myservo.write(this->PIN, 180);
|
||||
|
||||
this->position = 180;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::goMiddle() {
|
||||
this->myservo.write(this->PIN, 90);
|
||||
this->position = 90;
|
||||
}
|
||||
|
||||
int ServoMotorComponent::getPosition() {
|
||||
return this->position;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::setPin(int PIN) {
|
||||
this->PIN = PIN;
|
||||
this->myservo.attach(PIN);
|
||||
}
|
Reference in New Issue
Block a user