| Electronic Components Datasheet Search |
|
DEV-13042 Datasheet(PDF) 6 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-13042 Datasheet(HTML) 6 Page - SparkFun Electronics |
|
6 / 9 page ![]() // after the code has completed. int main() { // Variables to be used elsewhere in the program. uint16_t startTime, stopTime; mraa::I2c* pwm_i2c; // We need to create an I2c object tha t we can pass to // the pca9685 constructor. If you ha ve more than one // PCA9685 device on your bus (eithe r by stacking more // than one PWM block or by adding ex ternal boards via // the I2C Expansion Block), you'll n eed to create a // different I2c object for each one! pwm_i2c = new mraa::I2c(1); // Tell the I2c object which bu s it's on. pca9685 pwm(pwm_i2c, 0x40); // 0x40 is the default address f or the PCA9685. // In general usage, you don't need to worry about getting o r setting the // mode registers or the prescaler register. I'm including these lines here // just for example completeness purposes. cout<<"Current mode register values: 0x"<<hex<<pwm.readModeR egisters()<<endl; cout<<"Current prescaler: "<<dec<<static_cast<int16_t>(pwm.g etPrescaler())<<endl; pwm.setPrescaler(121); // There are four generic functions allowing the user to cha nge the start and // stop times of the various channels. Generally, however, you shouldn't ever // have to or want to use these, since there are more usefu l functions // available which will be covered below. pwm.setChlTime(RED, 0, 0); pwm.setChlDuty(BLUE, 0); pwm.setChlStart(GREEN, 0); pwm.setChlStop(GREEN, 0); pwm.setChlDuty(SERVO, 0); #ifdef LED_DEMO // When you call enableLEDMode(), you set the output to be a pproximately 400Hz // and inverted. Thus, a 0 output will be a 100% high outpu t. This allows us // to use the output to drive common anode LEDs. See the tu torial for an // example circuit. pwm.enableLEDMode(); // Back to this, just so you can compare the settings in LE D mode with the // default (which is actually LED mode). cout<<"Current mode register values: "<<hex<<pwm.readModeReg isters()<<endl; cout<<"Current prescaler: "<<dec<<static_cast<int16_t>(pwm.g etPrescaler())<<endl; for (uint8_t i = 0; i <= 100; i++) Page 6 of 9 |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |