|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2014-8-31 10:20:06
|
显示全部楼层
#include <stc12c5a60s2.h>
#include <nima.h>
#define uint unsigned int
sbit L_IN1=P0^0;
sbit L_IN2=P0^1;
sbit L_IN3=P0^2;
sbit L_IN4=P0^3;
sbit R_IN1=P0^4;
sbit R_IN2=P0^5;
sbit R_IN3=P0^6;
sbit R_IN4=P0^7;
void CAR_Left(void)
{
P0=0x99;
}
void main()
{
CAR_Left();
CCAP1L=0x38;
CCAP1H=0x38; //pwm1,P1.4,右轮
CCAP0L=0x70; //pwm0,p1.3,左轮
CCAP0H=0x70; //越大低电平时间越久
}
定义:
#ifndef _nima_H_
#define _nima_H_
#include "STC12C5A60S2.h"
void PWM_INIT(void)
{
CCON = 0;
CMOD = 0x02;
CL = 0x00;
CH = 0x00;
CCAPM0 = 0x42;
CCAPM1 = 0x42;
CR = 1;
}
#endif
这样好像也调不了。。。。。。 |
|