赞
踩
目录
原理:左轮定时器0调速,右轮定时器1调速,那么左转就是右轮速度大于左轮
main.c
- #include "motor.h"
- #include "delay.h"
- #include "uart.h"
- #include "time.h"
-
- extern char speedLeft; //此变量/函数是在别处定义的,要在此处引用
- extern char speedRight;
- void main()
- {
- Time0Init(); //定时器0初始化
- Time1Init(); //定时器1初始化
- UartInit(); //串口初始化
-
- while(1){
-
- speedLeft = 10; //10份单位时间全速运行,30份停止,所以慢,20ms是40份的500us
- speedRight = 40;
- Delay1000ms();
- Delay1000ms();
- speedLeft = 40;
- speedRight = 10;
- Delay1000ms();
- Delay1000ms();
-
- }
- }

motor.c
- #include "reg52.h"
-
-
- sbit Ri
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。