原文地址https://blog.csdn.net/superce/article/details/79248623
前进代码
/* USER CODE BEGIN 2 */
printf("INIT begin\n");
PCA9685_Go();
SetPWMFreq(50);
printf("INIT\n");
SetPWM(0, 0, SERVO045);
SetPWM(1, 0, SERVO135);
SetPWM(2, 0, SERVOMIN);
SetPWM(3, 0, SERVOMAX);
SetPWM(4, 0, SERVOMAX);
SetPWM(5, 0, SERVOMAX);
SetPWM(6, 0, SERVOMIN);
SetPWM(7, 0, SERVOMIN);
HAL_Delay(1000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
SetPWM(7, 0, SERVO090);
SetPWM(0, 0, SERVOMIN);
SetPWM(3, 0, SERVO135);
SetPWM(5, 0, SERVO090);
SetPWM(1, 0, SERVOMAX);
SetPWM(2, 0, SERVO045);
HAL_Delay(1000);
SetPWM(7, 0, SERVOMIN);
SetPWM(5, 0, SERVOMAX);
HAL_Delay(1000);
SetPWM(4, 0, SERVO045);
SetPWM(0, 0, SERVO045);
SetPWM(3, 0, SERVOMAX);
SetPWM(6, 0, SERVO045);
SetPWM(2, 0, SERVOMIN);
SetPWM(1, 0, SERVO135);
HAL_Delay(1000);
SetPWM(4, 0, SERVOMAX);
SetPWM(6, 0, SERVOMIN);
HAL_Delay(1000);
}
/* USER CODE END 3 */