|
刚用L298驱动了2个电机,写了个简单的测试程序,按照如下程序只有leftmoto电机工作,另一个电机却不动,为何啊?
#include <avr/io.h>
/*IN1-PD2,IN3-PD3,右电机ENA-PD4(OC1B),左电机ENB-PD5(OC1A)*/
#define rightmoto_zhen() PORTD|=0X04
#define rightmoto_fan() PORTD&=(~0X04)
#define rightmoto_control() PORTD&=(~0X10)
#define leftmoto_zhen() PORTD|=0X08
#define leftmoto_fan() PORTD|=(~0x08)
#define leftmoto_control() PORTD&=(~0X20)
int main(void)
{
DDRD|=0X3C;
PORTD=0XFF;
while(1)
{ //rightmoto_control();
//leftmoto_control();
rightmoto_fan();
leftmoto_zhen();
}
} |
|