#include <Servo.h>
Servo A;
int pos=0 ;
const int xdirPin = 44; // 方向引脚
const int xstepPin = 45; // 步进引脚
const int ydirPin = 32; // 方向引脚
const int ystepPin = 33; // 步进引脚
const int zdirPin = 42; // 方向引脚
const int zstepPin = 43; // 步进引脚
const int adirPin = 30; // 方向引脚
const int astepPin = 31; // 步进引脚
const int STEPS_PER_REV = 200;
#define ECHOPIN A0
#define TRIGPIN A1
void setup() {
// put your setup code here, to run once:
pinMode(TRIGPIN, OUTPUT);
pinMode(ECHOPIN, INPUT);
pinMode(8,OUTPUT);
pinMode(xstepPin,OUTPUT);
pinMode(xdirPin,OUTPUT);
pinMode(ystepPin,OUTPUT);
pinMode(ydirPin,OUTPUT);
pinMode(zstepPin,OUTPUT);
pinMode(zdirPin,OUTPUT);
pinMode(astepPin,OUTPUT);
pinMode(adirPin,OUTPUT);
A.attach(2); // Servo对象连接在9号引脚
delay(10);
}
void loop() {
for(int pos=20;pos<=130;pos++)
{
A.write(pos);
}
delay(3000);
for(int pos=130;pos>=20;pos--)
{
A.write(pos);
}
delay(3000);
digitalWrite(xdirPin,LOW);
digitalWrite(ydirPin,HIGH);
digitalWrite(zdirPin,LOW);
digitalWrite(adirPin,HIGH);
for(int x = 0; x < STEPS_PER_REV; x++) {
digitalWrite(xstepPin,HIGH);
digitalWrite(ystepPin,HIGH);
digitalWrite(zstepPin,HIGH);
digitalWrite(astepPin,HIGH);
delayMicroseconds(400);
digitalWrite(xstepPin,LOW);
digitalWrite(ystepPin,LOW);
digitalWrite(zstepPin,LOW);
digitalWrite(astepPin,LOW);
delayMicroseconds(400);
}
}
一直报错error: stray '\320' in program const