程序:
int IN1=4;
int IN2=5;
int IN3=6;
int IN4=7;
void setup()
{
Serial.begin(9600);
int i;
for (i=4;i<=7;i++) //为Ardunio 电机驱动板
pinMode(i,OUTPUT); //设置数字端口4,5,6,7为输出模式
for (i=4;i<=7;i++)
digitalWrite(i,HIGH); //设置数字端口4,5,6,7为HIGH,电机保持不动
pinMode(10,OUTPUT);//设置数字端口10 11为输出模式
pinMode(11,OUTPUT);
}
void loop()
{
if(Serial.available())
{
char num = Serial.read();
Serial.println(num);
if(num == 'qian')
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
if(num == 'hou')
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
if(num=='ting')
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
else
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(10,LOW);
}
}
错误提示:
stray"\302"in program
很急很急,跪求大佬!!!
|