介绍
这是一块32路舵机驱动板,做舵机机器人非常方便。主控用的esp8266.
3D图片如下图所示:
实物图如下:
?
?
测试代码:
/***************************************************
对于ARDUINO UNOS,这是SCL->模拟5,SDA - >模拟4
****************************************************/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41);
#define SERVOMIN 150
#define SERVOMAX 600
void setup() {
Serial.begin(115200);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm1.begin();
pwm.setPWMFreq(50); // Analog servos run at ~50 Hz updates
pwm1.setPWMFreq(50); // Analog servos run at ~50 Hz updates
}
void loop() {
for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
for(int i=0;i<15;i++)
{
pwm.setPWM(i, 0, pulselen);
pwm1.setPWM(i, 0, pulselen);
}
delay(1);
}
delay(500);
for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
for(int i=0;i<15;i++)
{
pwm.setPWM(i, 0, pulselen);
pwm1.setPWM(i, 0, pulselen);
}
delay(1);
}
delay(500);
}
|