#include <Arduino.h>
#include "mode.h"
const int xdirPin = 3, ydirPin = 4;
const int xstepPin = 5, ystepPin = 6;
const int enablePin = 7;
const int xlimitPin = A0, ylimitPin = A1;
bool dingwei = false, chongfu = false;
bool xlimitJudge = false, ylimitJudge = false;
int Plist = 0, frequency = 2;
long x_coordinate = 0, y_coordinate = 0;
long Px_axis[First_listSize], Py_axis[First_listSize];
long Ax_axis[Second_listSize], Ay_axis[Second_listSize];
void setup() {
Serial.begin(115200);
pinMode(enablePin, OUTPUT);
pinMode(xdirPin, OUTPUT); pinMode(ydirPin, OUTPUT);
pinMode(xstepPin, OUTPUT); pinMode(ystepPin, OUTPUT);
pinMode(xlimitPin, INPUT_PULLUP); pinMode(ylimitPin, INPUT_PULLUP);
digitalWrite(enablePin, LOW);
Serial.println("啟用預先校正,請耐心等待!");
Correction();
Serial.println("Input char, 請輸入字元!");
}
void loop() {
if (Serial.available() > 0) {
char keys = Serial.read();
switch (keys) {
case 'C':
Correction();
dingwei = false; chongfu = false;
break;
case 'P':
Point();
break;
case 'A':
Again();
break;
case 'R':
for (int i = 0; i < Plist; i++) {
Px_axis[i] = 0; Py_axis[i] = 0;
}
Plist = 0; chongfu = false;
Serial.println("點位已重設!");
break;
default:
if (keys >= '1' && keys <= '9' && keys != '5') {
dingwei = true;
motor_control(keys);
}
break;
}
}
}