找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3133|回复: 0
打印 上一主题 下一主题
收起左侧

飞思卡尔智能车源程序

[复制链接]
跳转到指定楼层
楼主


单片机源程序如下:
  1. #include "stm32f10x.h"
  2. #include"duoji.h"
  3. #include<delay.h>
  4. #include"running.h"
  5. #include"ad.h"
  6. #include"infrared.h"
  7. #include<stdio.h>
  8. int main(void)
  9. {         
  10.          int u;
  11.          short ad;
  12.                 delay_init();
  13.                 Adc_Init();
  14.     duoji_Init(199,7199);
  15.                 TIM4_PWM_Init();
  16.     running_Init(299);
  17.                  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
  18.                 TIM_SetCompare2(TIM3,15);
  19.                 infrared_Init();
  20.                 while(1)
  21.                 {
  22.                         u=return1();        
  23.                   ad=Get_adc1()-Get_adc1();
  24.                         if(u==3){
  25.                                 running_Init(1000);
  26.                         }

  27.                         
  28.                         if(ad>-2&&ad<0)
  29.                         {
  30.                                 TIM_SetCompare2(TIM3,20);
  31.                                 delay_ms(1000);
  32.                         
  33.                         }
  34.                         
  35.                         if(ad>0&&ad<2)
  36.                         {
  37.                                 TIM_SetCompare2(TIM3,10);
  38.                                 delay_ms(2000);
  39.                
  40.                         }
  41.                                 if(ad<-2)
  42.                         {
  43.                                 TIM_SetCompare2(TIM3,25);
  44.                                 delay_ms(2000);
  45.                         
  46.                         }
  47.                                 if(ad>2)
  48.                         {
  49.                                 TIM_SetCompare2(TIM3,5);
  50.                                 delay_ms(2000);

  51.                         }
  52.                         if(ad==0)
  53.                         {
  54.                                 TIM_SetCompare2(TIM3,15);
  55.                                 delay_ms(500);
  56.                         }
  57.         }
  58. }
复制代码

所有资料51hei提供下载:
car.7z (186.3 KB, 下载次数: 30)

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表