0

Adafruit 16-Channel 12-bit PWM/Servo Shield
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit 16-Channel 12-bit PWM/Servo Shield

by tylerwr on Wed Nov 04, 2015 9:30 am

I got the Adafruit 16-Channel 12-bit PWM/Servo Shield and it works great with the Arduino UNO using the supplied library.

I just got an Arduino Zero (32bit ARM processor) and I get the following error when I try an compile the servo example code.

Code: Select all | TOGGLE FULL SIZE
 Arduino: 1.6.5 (Windows 7), Board: "Arduino Zero (Programming Port)"

C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp: In member function 'void Adafruit_PWMServoDriver::begin()':
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:25:15: error: 'Wire1' was not declared in this scope
  #define WIRE Wire1
               ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:36:2: note: in expansion of macro 'WIRE'
  WIRE.begin();
  ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp: In member function 'void Adafruit_PWMServoDriver::setPWM(uint8_t, uint16_t, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:25:15: error: 'Wire1' was not declared in this scope
  #define WIRE Wire1
               ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:75:3: note: in expansion of macro 'WIRE'
   WIRE.beginTransmission(_i2caddr);
   ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp: In member function 'uint8_t Adafruit_PWMServoDriver::read8(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:25:15: error: 'Wire1' was not declared in this scope
  #define WIRE Wire1
               ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:120:3: note: in expansion of macro 'WIRE'
   WIRE.beginTransmission(_i2caddr);
   ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp: In member function 'void Adafruit_PWMServoDriver::write8(uint8_t, uint8_t)':
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:25:15: error: 'Wire1' was not declared in this scope
  #define WIRE Wire1
               ^
C:\Program Files (x86)\Arduino\libraries\Adafruit_PWM_Servo_Driver\Adafruit_PWMServoDriver.cpp:129:3: note: in expansion of macro 'WIRE'
   WIRE.beginTransmission(_i2caddr);
   ^
Error compiling.


How can I fix this?

I also have your ADS1015 board and it compiles and runs fine on the Zero.

Any help is appreciated
Last edited by adafruit_support_mike on Thu Nov 05, 2015 12:50 am, edited 1 time in total.
Reason: added CODE tags

tylerwr
 
Posts: 2
Joined: Wed Nov 04, 2015 9:20 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by adafruit_support_mike on Thu Nov 05, 2015 12:55 am

It looks like you're getting caught by the board identification logic. This section of the library's header file is causing the problem:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_PWMServoDriver.h>
#include <Wire.h>
#if defined(__AVR__)
 #define WIRE Wire
#elif defined(CORE_TEENSY) // Teensy boards
 #define WIRE Wire
#else // Arduino Due
 #define WIRE Wire1
#endif
The official solution would be to look through the Zero's documentation, find what macro it uses as a board identifier, and add a case that defines WIRE appropriately.

A faster but more fragile option would be to replace the code above with a define for whatever Wire library the Zero uses.

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by tylerwr on Fri Nov 06, 2015 7:28 am

Thank you. I was able to comment that part out and just #define WIRE Wire and it worked great.

//#if defined(__AVR__)
#define WIRE Wire
//#elif defined(CORE_TEENSY) // Teensy boards
// #define WIRE Wire
//#else // Arduino Due
// #define WIRE Wire1
//#endif

tylerwr
 
Posts: 2
Joined: Wed Nov 04, 2015 9:20 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by adafruit_support_mike on Fri Nov 06, 2015 11:59 pm

Good to hear. Happy hacking!

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by deuxbouh on Mon Nov 16, 2015 5:31 pm

Hello,

Thank you for this answer, I found out (after 2 hours of seach) why this was not woking with my arduino Due !
It uses the Wire1 by deflaut...

Can I suggest you add this information in the documentation about "Adafruit 16-channel PWM/Servo" ?

I didn't found the information anywhere but here.

Regards,

deuxbouh
 
Posts: 9
Joined: Fri Oct 25, 2013 5:45 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by adafruit_support_mike on Mon Nov 16, 2015 11:36 pm

I'll talk to the folks who manage the library.

adafruit_support_mike
 
Posts: 55967
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by adafruit2 on Tue Nov 17, 2015 1:39 pm

hiya we've pushed an updated. basically we have 250 products we have to test with & adapt to each new Arduino compatible product - so it may take time to get to them all :)

adafruit2
Site Admin
 
Posts: 18047
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by spinoza1791 on Thu Jul 21, 2016 7:09 pm

Thank God for you tylerwr! Trying to get my Feather M0 to work with the Servo breakout and this worked. Without you, I would have been completed stuck. Adafruit, please add this to FAQ or some docs related to using the MO Feather with the 16-Channel Servo breakout. Thx!

spinoza1791
 
Posts: 8
Joined: Thu Apr 28, 2016 2:30 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield

by polypagan on Sat Dec 22, 2018 5:29 pm

I managed to make this work by adding:

TwoWire Wire1;

in global scope.

Works on ESP8266 in any case. I would expect that to be the correct syntax, usage.

polypagan
 
Posts: 2
Joined: Mon May 06, 2013 1:46 pm

Please be positive and constructive with your questions and comments.