找回密码
 立即注册

QQ登录

只需一步,快速开始

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

STM32智能电磁寻迹小车.速度999 1.0炒鸡稳版源码

[复制链接]
跳转到指定楼层
楼主
ID:319398 发表于 2018-4-30 15:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大三课程设计,电磁传感器是自己设计制作的,只需根据自己测得的电磁强度改一下参数即可使用

STM32单片机源程序如下:
  1. #include "stm32f10x.h"
  2. #include "adc.h"
  3. #include "lcd.h"
  4. #include "delay.h"
  5. #include "usart.h"
  6. #include "pwm.h"
  7. #include "key.h"
  8. #include "math.h"

  9. u16 adc0=0,adc1=0,adca=0,adcb=0, adc3=0;
  10. float cha1=0,cha2=0;
  11. double v0,v1;


  12. extern u32 s1,s2,s3,s4;

  13. int main (void)
  14. {
  15.        
  16.         s1=s3=5,s2=s4=5;
  17.         delay_init();
  18.         uart_init(115200);
  19.         LCD_Init();
  20.         adc_init();
  21.         POINT_COLOR=RED;
  22.         LCD_Clear(GRAY);
  23.         POINT_COLOR=RED;
  24.          
  25.         key();

  26.        
  27.         LCD_ShowString(60,50,200,16,16,"ADC_Right:");             
  28.         LCD_ShowString(60,70,200,16,16,"w1:");
  29.   LCD_ShowString(60,90,200,16,16,"ADC_Left:");             
  30.         LCD_ShowString(60,110,200,16,16,"w3:");
  31.         LCD_ShowString(60,130,200,16,16,"cha1:");
  32.         LCD_ShowString(60,150,200,16,16,"cha2:");

  33.        
  34.         while(1)
  35.         {
  36.                 adca=get_adc(ADC_Channel_0);
  37.           adcb=get_adc(ADC_Channel_1);
  38.                 if(adca>adcb)
  39.                 {
  40.                    cha1=adca-adcb;
  41.                         if(200>cha1)
  42.                          {
  43.                           s1=999;
  44.         s2=999;
  45.                     s3=999;
  46.         s4=999;
  47.                          }
  48.                         if(200<cha1)
  49.                                 {
  50.                                         if(cha1<600)
  51.                                         {
  52.                                                 s1=700;
  53.                                                 s2=700;
  54.                                                 s3=600;
  55.                                                 s4=600;
  56.                                         }
  57.                                         if(cha1>=600)
  58.                                         {
  59.                                         if(cha1<800)
  60.                                  {
  61.                                   s1=800;
  62.           s2=800;
  63.                       s3=400;
  64.           s4=400;
  65.                                  }
  66.                                   if(cha1>=800)
  67.                                          {
  68.                                         s1=999;
  69.           s2=999;
  70.                       s3=200;
  71.           s4=200;
  72.                                          }
  73.                                  }
  74.                 }               
  75.         }               
  76.     else       
  77.                 {                       
  78.      if(adcb>=adca)
  79.                  {
  80.                          cha2=adcb-adca;
  81.                    if(300>=cha2)
  82.                          {
  83.                           s1=999;
  84.         s2=999;
  85.                     s3=999;
  86.         s4=999;
  87.                          }
  88.                         if(300<cha2)
  89.                                 {
  90.                                         if(cha2<1000)
  91.                                         {
  92.                                                 s1=500;
  93.                                                 s2=500;
  94.                                                 s3=700;
  95.                                                 s4=700;
  96.                                         }
  97.                                         if(cha2>=1000)
  98.                                         {
  99.                                         if(cha2<1500)
  100.                                  {
  101.                                   s3=800;
  102.           s4=800;
  103.                       s1=400;
  104.           s2=400;
  105.                                  }
  106.                                   if(cha2>=1500)
  107.                                          {
  108.                                         s3=900;
  109.           s4=900;
  110.                       s1=300;
  111.           s2=300;
  112.                                          }
  113.                                  }
  114.                  }
  115.            }
  116.          }
  117.                 LCD_ShowxNum(156,50,adca,4,16,0);//显示ADC的值
  118.                
  119.                 LCD_ShowxNum(156,90,adcb,4,16,0);//显示ADC的值
  120.           
  121.                 LCD_ShowxNum(156,130,cha1,4,16,0);
  122.                 LCD_ShowxNum(156,150,cha2,4,16,0);
  123.     LCD_ShowxNum(156,70,s1,4,16,0);
  124.                  LCD_ShowxNum(156,110,s3,4,16,0);
  125.                 GPIO_ResetBits(GPIOB,GPIO_Pin_5);
  126.     pwm_init();               
  127.   
  128.                 }
  129.   }
复制代码

所有资料51hei提供下载:
智能寻迹小车.速度999 1.0炒鸡稳版.rar (339.15 KB, 下载次数: 101)


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

使用道具 举报

沙发
ID:274340 发表于 2018-6-25 12:51 | 只看该作者
电磁传感器设计也附上嘛
回复

使用道具 举报

板凳
ID:379039 发表于 2018-7-26 13:10 | 只看该作者
没有驱动
回复

使用道具 举报

地板
ID:415697 发表于 2018-10-27 20:39 | 只看该作者
居然没有电磁传感
回复

使用道具 举报

5#
ID:536022 发表于 2019-7-24 14:53 | 只看该作者
有环岛程序吗?
回复

使用道具 举报

6#
ID:932417 发表于 2021-7-9 09:06 | 只看该作者
想问下STM32F103能能用吗,谢谢
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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