欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: stm32單片機ps2+舵機控制成功版源碼 [打印本頁]

作者: hanson0520    時間: 2018-6-7 22:16
標題: stm32單片機ps2+舵機控制成功版源碼
ps2+舵機控制成功版

單片機源程序如下:


  1. #include "stm32f10x.h"      
  2. #include  "PWM_OUT.h"
  3. #include "LED.h"
  4. #include "sys.h"   
  5. #include "adc.h"  
  6. #include "delay.h"
  7. #include "bsp_usart.h"


  8. #define key1 PBin(0)
  9. #define key2 PBin(1)

  10. extern __IO uint16_t ADC_ConvertedValue[NOFCHANEL];

  11.   u16 CCR1_Val=60;
  12.         float uu=0 ;
  13.         float bb=0 ;
  14. u16 TT;       
  15. int main(void)
  16. {       
  17.   
  18.                 USART_Config();
  19.   ADCx_Init();

  20.                
  21.        
  22.        
  23.        
  24.        
  25.   TIM3_GPIO_Config();
  26.           GPIO_InitTypeDef GPIO_InitStructure;

  27.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB,ENABLE);//使能PORTA,PORTC時鐘
  28.        
  29.         GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_1;//PE1
  30.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //設置成上拉輸入  
  31.         GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化GPIOA15
  32.        
  33.         GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_0;//PE0
  34.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //設置成上拉輸入
  35.         GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化GPIOC5

  36.         GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_0;//PA0
  37.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //PA0設置成輸入,默認下拉          
  38.         GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.0
  39.        



  40.         TIM3_PWM_Init();
  41.         Delay(0x0FFFFF);
  42.                 Delay(0x0FFFFF);
  43.   while(1)
  44.         {   
  45.        
  46.                         uu =(float) ADC_ConvertedValue[0]*170/4096+60;
  47.                    TT=(int)uu;
  48.                         //bb=(float) ADC_ConvertedValue[1]/4096*3.3;
  49.                                 printf("\r\n CH0 value = %d V \r\n",TT);
  50.                         printf("\r\n CH1 value = %f V \r\n",bb);
  51.                
  52. // uu=(float)ADC_ConvertedValue[0]*(170/4096)+145;
  53. //        CCR1_Val=(u16)uu;
  54.                
  55. //       
  56. //                if(key2==0&&key1==1)
  57. //                {   TT=CCR1_Val;
  58. //        TT+=1;
  59. //               
  60. //if(TT>=230)TT=230;
  61. //                     CCR1_Val=TT;}

  62. //       
  63. //     if(key1==0&&key2==1)
  64. //{TT-=1;
  65. //if(TT<=60)TT=60;
  66. //  CCR1_Val=TT;
  67. //         }

  68.        
  69.    TIM_SetCompare1(TIM3,TT);  
  70.                

  71.                 Delay(0x003FFF);
  72.                
  73.   }
  74. }
復制代碼

所有資料51hei提供下載:
ps2 舵機試驗成功版.rar (296.91 KB, 下載次數: 58)



作者: Grrizzly    時間: 2018-8-3 09:56
這是整個程序?

作者: 新生郡主ziming    時間: 2021-6-5 18:28
有接線圖嗎  哥
作者: wsy允    時間: 2021-7-9 09:22
這個stm32f103能用嗎




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1