#include

#define uchar unsigned char

#define uint unsigned int

uchar temp,signal,tt1,t0,t1,t2,t3,t4,t5,t6;

void delay_1ms(uint d)

{

uint i;

while(d--)

for(i=0;i<75;i++);

}

void motor_run()                   //电机起动

{

P1=0x35;

delay_1ms(200);

P1=0x53;

delay_1ms(10);

/*        ENA=1;

OUT1=0;

OUT2=1;

delay_1ms(800);

OUT2=0;

delay_1ms(200);

ENB=1;

OUT4=0;

OUT3=1;

delay_1ms(800);

OUT3=0;

delay_1ms(200);

*/

}

void motor_left()                         //左进

{

P1=0x30;

delay_1ms(200);

P1=0x00;

delay_1ms(20);

}

void motor_right()                   //右进

{

P1=0x05;

delay_1ms(200);

P1=0x00;

delay_1ms(20);

}

void motor_big_right()                         //粗右进

{

P1=0x55;

delay_1ms(200);

P1=0x00;

delay_1ms(20);

}

void motor_big_left()

{

P1=0x33;

delay_1ms(200);

P1=0x00;

delay_1ms(20);

}

void motor_stop()                                        //电机停止

{

P1=0x00;

}

void motor_back()

{

P1=0x53;

}

void main()

{

t0=0;

t1=0;

t2=0;

t3=0;

t4=0;

t5=0;

t6=0;

tt1=0;

EA=1;

ET1=1;

TR1=1;

TMOD=0x01;

TH1=-(1000/256);

TL1=-(1000%256);

while(1)

{

temp=P2;

signal=temp&0xff;                   //得到红外反向信号

switch(signal)

{

case 0xff:           //无偏差

motor_run();

t0++;

if(t0==10)

{

t0=0;

motor_left();

motor_right();

}

t1=t2=t3=t4=t5=t6=0;

break;

case 0xfd:           //1轮右偏

motor_big_left();

t1++;

if(t1==4)

{

t1=0;

motor_left();

}

t0=t2=t3=t4=t5=t6=0;

break;

case 0xef:            //4轮左偏

motor_big_right();

t2++;

if(t2==4)

{

t2=0;

motor_right();

}

t0=t1=t3=t4=t5=t6=0;

break;

case 0xfb:     //2轮右偏出轨

case 0xf9:           //1、2轮右偏

motor_big_left();

t3++;

if(t3==4)

{

t3=0;

motor_left();

}

t0=t1=t2=t4=t5=t6=0;

//                                delay_1ms(10);

break;

case 0xdf:           //5左偏出轨

case 0xcf:      //4、5轮左偏

motor_big_right();

t4++;

if(t4==4)

{

t4=0;

motor_right();

}

t0=t1=t2=t3=t5=t6=0;

//                                delay_1ms(10);

break;

case 0xfe:           //0最右偏出轨

case 0xfa:

motor_big_left();

t5++;

if(t5==1)

{

t5=0;

motor_left();

motor_left();

}

t0=t1=t2=t3=t4=t6=0;

//                                delay_1ms(10);

break;

case 0xbf:     //6最左偏出轨

case 0x9f:

motor_big_right();

t6++;

if(t6==1)

{

t6=0;

motor_right();

motor_right();

}

t0=t1=t2=t3=t4=t5=0;

//                                delay_1ms(10);

break;

case 0xeb:         //前两传感器压在黑线上

case 0xdb:         //后两传感器压在黑线上

case 0xbe:         //中间两传感器压在黑线上

case 0xac:                 //前四传感器压在黑线上

case 0x9a:                //后四传感器压在黑线上

motor_back();

delay_1ms(200);

motor_stop();

//                                delay_1ms(1000);

default:

//                                motor_back();

//                                delay_1ms(50);

//                                motor_left();

//                                motor_right();

break;

}

}

}

/*void time1() interrupt 3

{

TH1=-(1000/256);

TL1=-(1000%256);

tt1++;

if(tt1==300)

{

motor_back();

//        delay_1ms(1);

tt1=0;

}

} */

循迹小车c语言程序51单片机,51单片机循迹小车Proteus仿真程序相关推荐

  1. 智能循迹避障小车C语言程序编写思路,基于单片机的智能小车红外避障循迹系统设计与制作...

    余秀玲 余秀娟 摘 要:随着科技的高速发展,人们对生活质量的要求越来越高,无人驾驶汽车已经被广为研发和试用,由此智能小车的快速发展也是在情理之中.通过对基于单片机的智能小车的硬件及软件设计分析,实现红 ...

  2. 智能循迹避障小车C语言程序编写思路,设计一个循迹避障一体的智能小车的资料和代码及电路图详细概述...

    一) 小车功能实现描述 利用光电传感(红外对射管,红外发射与接收二极管组成)检测黑白线,实现小车能跟着白线(或黑线)行走,同时也可避开障碍物,即小车寻迹过程中,若遇障碍物可自行绕开,绕开后继续寻迹. ...

  3. 51单片机c语言程序执行顺序,51单片机程序执行流程详细分析

    这里是一个循环,根据DJNZ指令的功能:每执行一次DJNZ RO, IDATALOOP就将R0的值减1,若R0的值不为0则就跳到IDATALOOP地址去.很显然这是一个循环,那么RO的值是多少呢,在以 ...

  4. 4wd智能小车c语言程序,智能盒子oj

    1电机驱动系统 想要让小车运动起来,需要将电能转化为机械能,最后成为小车的动能.小车的动能是由4个直流电机提供的,而控制电动机运动的是一个电机驱动模块,模块与Arduino uno或其他控制器相连,负 ...

  5. 避障跟随测距c语言程序,红外避障小车c语言程序.pdf

    智能小车红外避障智能小车红外避障 c 语言程序语言程序 #include bit RandomFactor = 0 ; bit RandomFactorBuf = 0 ; #include #defi ...

  6. 单片机流水灯全亮c语言程序,终极流水灯单片机C语言程序.doc

    终极流水灯单片机C语言程序 #include #include #define uint unsigned int sbit beep=P2^3; void ji_ou(); void sx(); v ...

  7. adc0809 c语言程序,ADC0809 模数转换 89C52单片机C语言程序(电压表)

    很不错的程序哦! ADC0809 模数转换 89C52单片机C语言程序 阅读108 评论0 字号:大中小 /**********[数字电压温度表]***********/ #include #defi ...

  8. 基于51单片机的酒精浓度检测量仪proteus仿真程序原理图设计数码管液晶LCD1602显示

    硬件设计 (末尾附文件) 仿真文件中的酒精传感器均是用滑动变阻器来模拟 基于数码管显示: 基于LCD1602显示: 程序设计 //程序头函数 #include <reg52.h> //显示 ...

  9. c32循迹小车c语言程序,STM32小车红外黑线循迹源程序

    /********************************* 深圳市航太电子 ******************************* * 实 验 名 :小车红外黑线循迹 * 实验说明 ...

  10. c32循迹小车c语言程序,stm32篇--小车循迹

    小车的循迹算法 循迹小车使用红外对射寻黑线,根据轨道的不同,我使用了两种不同算法: (1)第一种是在轨道外有影响的,比如轨道外有黑色,车出去一点就会碰到黑色,那就是检测到歪了之后除非检测它 回来了,否 ...

最新文章

  1. Yann LeCun:距离“真正的” AI,我们还缺什么?
  2. haoop格式化做的工作
  3. 快速撑握C#知识点之变量,类型及类型转换
  4. 013实现使用两个堆栈队列(keep it up)
  5. linux中的目录结构---Linux学习笔记
  6. 盘点3个改变世界的AI项目,NLP/CV/BI,3个方向
  7. (水题)洛谷 - P1603 - 斯诺登的密码
  8. Windows server 2008 R2 服务器安装 MySql 5.6.36 64位绿色版 报系统错误1067
  9. UVALive5910 UVA1641 POJ4022 ASCII Area【水题+输入输出】
  10. java与js的split方法
  11. background-size属性
  12. 你要的 React 面试知识点,都在这了
  13. 阿里 OSS图片上传 —— 原生JS中使用
  14. 绘制一张透明背景的单色位图
  15. Unity场景渲染之自发光材质
  16. Excel 2010光标移动到单元格边框时,不显示小十字(亲自实践)
  17. 计算机word表格计算教程F9,Word表格数据计算与域操作
  18. 诚之和:3个月亏17亿,贝壳释放了什么信号?
  19. 学校计算机房仪器借用记录表,初中物理实验仪器借用登记表(全)
  20. 单元电路器件学习光耦器件

热门文章

  1. Windows10性能优化设置
  2. Unity内置管线Projector原理分析
  3. 应用wms仓库管理系统,提高第三方物流企业竞争力
  4. MATLAB-输入输出语句
  5. [渝粤教育] 西南科技大学 成本会计 在线考试复习资料(1)
  6. scala下载和安装——aboutyun
  7. C语言题目练习100例——题目+题目分析+源代码(91—100)
  8. 【GNN】图嵌入之 node2vec:网络的可扩展特征学习
  9. c语言 段错误 linux
  10. 「CG原画插画教程」超适合小白的,零基础原画学习攻略