-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*************************************************** | ||
This is a library for our Adafruit 16-channel PWM & Servo driver | ||
Pick one up today in the adafruit shop! | ||
------> http://www.adafruit.com/products/815 | ||
These displays use I2C to communicate, 2 pins are required to | ||
interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4 | ||
Adafruit invests time and resources providing this open source code, | ||
please support Adafruit and open-source hardware by purchasing | ||
products from Adafruit! | ||
Written by Limor Fried/Ladyada for Adafruit Industries. | ||
Modified by ADITYA.T | ||
BSD license, all text above must be included in any redistribution | ||
****************************************************/ | ||
|
||
#ifndef _ADAFRUIT_PWMServoDriver_H | ||
#define _ADAFRUIT_PWMServoDriver_H | ||
|
||
#if ARDUINO >= 100 | ||
#include "Arduino.h" | ||
#else | ||
#include "WProgram.h" | ||
#endif | ||
|
||
|
||
#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 Adafruit_PWMServoDriver { | ||
public: | ||
Adafruit_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 d); | ||
}; | ||
|
||
#endif |