用avr输出驱动l298n再驱动直流两个直流电机。可是编程总是出现错误,真的不太明白呀
#include <avr/io.h>
#include <avr/wdt.h>
//#include <util/delay.h>
#include <avr/interrupt.h>
#define Robot_Enable { PORTA |=(1<<PA5)} //电机使能
#define Robor_Disable { PORTA &=~(1<<PA5)} //电机禁止
#define D0 PORTA.0
#define D1 PORTA.1
#define D2 PORTA.2
#define D3 PORTA.3
void motor_ctl(void) //电机控制程序
{
if (PORTC.0==1) //向前
{
D0=1;
D1=0;
D2=1;
D3=0;
}
else if (PORTC.1==1) //向后
{
D0=0;
D1=1;
D2=0;
D3=1;
}
else if (PORTC.2==1) //向左
{
D0=0;
D1=1;
D2=1;
D3=0;
}
else if (PORTC.3==1) //向右
{
D0=1;
D1=0;
D2=0;
D3=1;
}
void port_init(void) //端口初始化
{
DDRA=0xFF;
PORTA=0xFF;
}
int main()
{
port_init();
while(1)
{
motor_ctl();
}
return 0;
}
}
出现错误../a.c:16: error: expected ')' before numeric constant
../a.c:18: error: expected ';' before numeric constant
../a.c:19: error: expected ';' before numeric constant
../a.c:20: error: expected ';' before numeric constant
../a.c:21: error: expected ';' before numeric constant
../a.c:23: error: expected ')' before numeric constant
../a.c:25: error: expected ';' before numeric constant
../a.c:26: error: expected ';' before numeric constant
../a.c:27: error: expected ';' before numeric constant
../a.c:28: error: expected ';' before numeric constant
../a.c:30: error: expected ')' before numeric constant
../a.c:32: error: expected ';' before numeric constant
../a.c:33: error: expected ';' before numeric constant
../a.c:34: error: expected ';' before numeric constant
../a.c:35: error: expected ';' before numeric constant
../a.c:37: error: expected ')' before numeric constant
../a.c:39: error: expected ';' before numeric constant
../a.c:40: error: expected ';' before numeric constant
../a.c:41: error: expected ';' before numeric constant
../a.c:42: error: expected ';' before numeric constant
|