-
Notifications
You must be signed in to change notification settings - Fork 0
/
PWMServoDriver.h
52 lines (39 loc) · 1.01 KB
/
PWMServoDriver.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef PWMServoDriver_h
#define PWMServoDriver_h
#if ARDUINO >= 100
# include "Arduino.h"
#else // if ARDUINO >= 100
# include "WProgram.h"
#endif // if ARDUINO >= 100
#define PCA9685_SUBADR1 0x2
#define PCA9685_SUBADR2 0x3
#define PCA9685_SUBADR3 0x4
#define PCA9685_MODE1 0x0
#define PCA9685_PRESCALE 0xFE
#define LED0_ON_L 0x6
#define LED0_ON_H 0x7
#define LED0_OFF_L 0x8
#define LED0_OFF_H 0x9
#define ALLLED_ON_L 0xFA
#define ALLLED_ON_H 0xFB
#define ALLLED_OFF_L 0xFC
#define ALLLED_OFF_H 0xFD
class PWMServoDriver {
public:
PWMServoDriver(uint8_t addr = 0x40);
void begin(void);
void reset(void);
void setPWMFreq(float freq);
void setPWM(uint8_t num,
uint16_t on,
uint16_t off);
void setPin(uint8_t num,
uint16_t val,
bool invert = false);
private:
uint8_t _i2cAddr;
uint8_t read8(uint8_t addr);
void write8(uint8_t addr,
uint8_t data);
};
#endif // ifndef PWMServoDriver_h