33 lines
647 B
C++
33 lines
647 B
C++
#include "ServoMotorComponent.h"
|
|
|
|
ServoMotorComponent::ServoMotorComponent(int PIN) {
|
|
this->PIN = PIN;
|
|
this->position = 0;
|
|
this->myservo.attach(PIN);
|
|
this->myservo.write(0);
|
|
}
|
|
|
|
void ServoMotorComponent::goLeft() {
|
|
this->myservo.write(0);
|
|
this->position = 0;
|
|
}
|
|
|
|
void ServoMotorComponent::goRight() {
|
|
this->myservo.write(180);
|
|
this->position = 180;
|
|
}
|
|
|
|
void ServoMotorComponent::goMiddle() {
|
|
this->myservo.write(90);
|
|
this->position = 90;
|
|
}
|
|
|
|
int ServoMotorComponent::getPosition() {
|
|
return this->position;
|
|
}
|
|
|
|
void ServoMotorComponent::setPin(int PIN) {
|
|
this->PIN = PIN;
|
|
this->myservo.attach(PIN);
|
|
}
|