I'm doing a project which requires 16 5v dc motors to be driven in PWM. So I have brought this board -
I'm using the #include <Adafruit_PWMServoDriver.h> library
My understanding was pwm.setPWM(0, 1, 4095) being setPWM(channel, on, off) will turn on pin 0 for most of the time and I will be getting around 100% of VCC. But I'm getting only around 1.5v from the PWM pin.
I need voltage in the range of 3v to 5v from the PWM pins for my motors. So now I am wondering what I am doing wrong and is it possible to get 100% of vcc from the PWM pins using the PCA9865 board?
This is my Arduino code :
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
#if defined(ARDUINO_ARCH_SAMD)
// for Zero, the output on USB Serial console, remove the line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif
void setup() {
#ifdef ESP8266
Wire.pins(2, 14); // ESP8266 can use any two pins, such as SDA to #2 and SCL to #14
#endif
Serial.begin(9600);
Serial.println("16 channel PWM test!");
pwm.begin();
pwm.setPWMFreq(1000); // This is the maximum PWM frequency
#ifdef TWBR
// save I2C bitrate
uint8_t twbrbackup = TWBR;
// must be changed after calling Wire.begin() (inside pwm.begin())
TWBR = 12; // upgrade to 400KHz!
#endif
}
void loop() {
pwm.setPWM(0, 1, 4095);
}
The VCC pin is just power for the chip itself. If you want to connect servos or LEDs that use the V+ pins, you MUST connect the V+ pin as well. The V+ pin can be as high as 6V even if VCC is 3.3V (the chip is 5V safe). We suggest connecting power through the blue terminal block since it is polarity protected.
The V+ connector block just connects to all the power pins of the servos (if servos are used).
For DC motors you need to add a logic level mosfet and kickback diode per channel.
The Adafruit site shows a big p-channel polarity protection mosfet that is not there on the Amazon/Adafruit board.
Leo..
You will see that the pin does not source very much current only a maximum of 10uA, but it will sink a lot more current about 20mA. So you can never get 5V from a pin to drive an LED. The output pin has a few modes it works in and you must pick the right mode for your application.