/ Adafruit_PWMServoDriver
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Adafruit_PWMServoDriver.h Source File

Adafruit_PWMServoDriver.h

00001 /*************************************************** 
00002   This is a library for our Adafruit 16-channel PWM & Servo driver
00003 
00004   Pick one up today in the adafruit shop!
00005   ------> http://www.adafruit.com/products/815
00006 
00007   These displays use I2C to communicate, 2 pins are required to  
00008   interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4
00009 
00010   Adafruit invests time and resources providing this open source code, 
00011   please support Adafruit and open-source hardware by purchasing 
00012   products from Adafruit!
00013 
00014   Written by Limor Fried/Ladyada for Adafruit Industries.  
00015   BSD license, all text above must be included in any redistribution
00016   
00017   Ported to mbed by Brian Dickman, mbed.org user bxd.
00018   
00019   Note: you are responsible for creating the I2C object, and setting
00020   frequency if desired.
00021  ****************************************************/
00022 
00023 #ifndef _ADAFRUIT_PWMServoDriver_H
00024 #define _ADAFRUIT_PWMServoDriver_H
00025 
00026 #include "mbed.h"
00027 
00028 
00029 #define PCA9685_SUBADR1 0x2
00030 #define PCA9685_SUBADR2 0x3
00031 #define PCA9685_SUBADR3 0x4
00032 
00033 #define PCA9685_MODE1 0x0
00034 #define PCA9685_PRESCALE 0xFE
00035 
00036 #define LED0_ON_L 0x6
00037 #define LED0_ON_H 0x7
00038 #define LED0_OFF_L 0x8
00039 #define LED0_OFF_H 0x9
00040 
00041 #define ALLLED_ON_L 0xFA
00042 #define ALLLED_ON_H 0xFB
00043 #define ALLLED_OFF_L 0xFC
00044 #define ALLLED_OFF_H 0xFD
00045 
00046 
00047 class Adafruit_PWMServoDriver {
00048  public:
00049   Adafruit_PWMServoDriver(I2C *i2c, uint8_t addr = 0x40);
00050   void begin(void);
00051   void reset(void);
00052   void setPWMFreq(float freq);
00053   void setPWM(uint8_t num, uint16_t on, uint16_t off);
00054 
00055  private:
00056   I2C *_i2c;
00057   uint8_t _i2caddr;
00058 
00059   uint8_t read8(uint8_t addr);
00060   void write8(uint8_t addr, uint8_t d);
00061 };
00062 
00063 #endif