-
2.STM32多路舵机控制程序.rar下载
资源介绍
#define POSA 0
#define POSB 500
#define POSC 1000
#define POSD 1500
#define POSE 2000
#define POSF 2500
#define POSG 0
/**********************************************************************************/
/*****************************Ö÷º¯Êý***********************************************/
int main(void)
{
Timer_Init(); //¶¨Ê±Æ÷³õʼ»¯
SysTick_Init(); //ϵͳµÎ´ð¶¨Ê±Æ÷³õʼ»¯
GPIO_Config(); //GPIO³õʼ»¯
USART1_Config(); //³õʼ»¯´®¿Ú1
USART3_Config(); //³õʼ»¯´®¿Ú3
Timer_ON(); //¿ªÆô¶¨Ê±Æ÷
while (1)
{
/*CPWM[0]=POSA;CPWM[1]=POSA;CPWM[2]=POSA;CPWM[3]=POSA;CPWM[4]=POSA;CPWM[5]=POSA;
CPWM[6]=POSA;CPWM[7]=POSA;CPWM[8]=POSA;CPWM[9]=POSA;CPWM[10]=POSA;CPWM[11]=POSA;
CPWM[12]=POSA;CPWM[13]=POSA;CPWM[14]=POSA;CPWM[15]=POSA;CPWM[16]=POSA;CPWM[17]=POSA;
CPWM[18]=POSA;CPWM[19]=POSA;CPWM[20]=POSA;CPWM[21]=POSA;CPWM[22]=POSA;CPWM[23]=POSA;
Delay_ms(1000);*/
CPWM[0] =POSB;CPWM[1] =POSB;CPWM[2] =POSB;CPWM[3] =POSB;CPWM[4] =POSB;CPWM[5] =POSB;
CPWM[6] =POSB;CPWM[7] =POSB;CPWM[8] =POSB;CPWM[9] =POSB;CPWM[10]=POSB;CPWM[11]=POSB;
CPWM[12]=POSB;CPWM[13]=POSB;CPWM[14]=POSB;CPWM[15]=POSB;CPWM[16]=POSB;CPWM[17]=POSB;
CPWM[18]=POSB;CPWM[19]=POSB;CPWM[20]=POSB;CPWM[21]=POSB;CPWM[22]=POSB;CPWM[23]=POSB;
Delay_ms(1000);
CPWM[0]=1500;CPWM[1]=1500;CPWM[2]=1500;CPWM[3]=1500;CPWM[4]=1500;CPWM[5]=1500;
CPWM[6]=1500;CPWM[7]=1500;CPWM[8]=1500;CPWM[9]=1500;CPWM[10]=1500;CPWM[11]=1500;
CPWM[12]=1500;CPWM[13]=1500;CPWM[14]=1500;CPWM[15]=1500;CPWM[16]=1500;CPWM[17]=1500;
CPWM[18]=1500;CPWM[19]=1500;CPWM[20]=1500;CPWM[21]=1500;CPWM[22]=1500;CPWM[23]=1500;
Delay_ms(1000);
CPWM[0]=2300;CPWM[1]=2300;CPWM[2]=2300;CPWM[3]=2300;CPWM[4]=2300;CPWM[5]=2300;
CPWM[6]=2300;CPWM[7]=2300;CPWM[8]=2300;CPWM[9]=2300;CPWM[10]=2300;CPWM[11]=2300;
CPWM[12]=2300;CPWM[13]=2300;CPWM[14]=2300;CPWM[15]=2300;CPWM[16]=2300;CPWM[17]=2300;
CPWM[18]=2300;CPWM[19]=2300;CPWM[20]=2300;CPWM[21]=2300;CPWM[22]=2300;CPWM[23]=2300;
Delay_ms(1000);
}
}
/*******
- 上一篇: 舵机控制器STM32源程序20路
- 下一篇: STM32F10x舵机控制