Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PCA9685.h
- Committer:
- Kotttaro
- Date:
- 2021-12-17
- Revision:
- 0:4466d7fb25e2
File content as of revision 0:4466d7fb25e2:
#ifndef _PCA9685_H
#define _PCA9685_H
//#if ARDUINO >= 100
// #include "Arduino.h"
//#else
// #include "WProgram.h"
//#endif
#include"mbed.h"
#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 PCA9685 {
public:
//PCA9685(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 i2c_addr;
uint8_t read8(uint8_t addr);
void write8(uint8_t addr, uint8_t d);
};
#endif