-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniRC.cpp
More file actions
31 lines (26 loc) · 851 Bytes
/
MiniRC.cpp
File metadata and controls
31 lines (26 loc) · 851 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
29
30
31
#include "MiniRC.h"
/******************************************
Servos
******************************************/
/**************************************************************************/
/*!
@brief Create a Servo object, un-initialized!
You should never call this, instead have the {@link MatrixMini}
give you a Servo object with {@link MatrixMini.getServo}
*/
/**************************************************************************/
void MiniRC::begin(int ver, int pin){
_pin = pin;
_ver = ver;
if (_ver == 2){
_RCServo.attach(_pin); // version 2 use MCU's PWM to trigger the servo motor
}
}
void MiniRC::set(int angle) {
if (_ver == 2){
_RCServo.write(angle); // version 2 use MCU's PWM to trigger the servo motor
}
else{
setPWM_PCA9685(_pin, map(angle, 0, 180, 105, 515));
}
}