56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
|
|
/* ***************************************************************** *
|
|
* Arduino Nano (blue PCB)
|
|
* ----------------------------------
|
|
* +-°°°-+
|
|
* LED<--D13 ~ <-----| °°° |------>D12 --> Z.In2
|
|
* +3V3 --| |------>D11 ~ --> Servomotor
|
|
* AREF --| |------>D10 ~
|
|
* Y.I1<-D14 A0 --| |------>D9 ~ --> Z.In3
|
|
* Y.I2<-D15 A1 --| |------>D8 --> Z.In4
|
|
* Y.I3<-D16 A2 --| |------>D7 I4
|
|
* Y.I4<-D17 A3 --| |------>D6 ~
|
|
* D18 A4 --| |------>D5 ~ --> X.In1
|
|
* D19 A5 --| |-- D4 --> X.In2
|
|
* D20 A6 --| |-- D3 I1--> X.In3
|
|
* D21 A7 --| |-- D2 I0--> X.In4
|
|
* +5V --| |<------GND<----- GND
|
|
* RES --| |-- RES
|
|
* GND-->GND ------->| |-- D0 Rx0
|
|
* VIN --| 15 |-- D1 Tx0
|
|
* +-----+
|
|
* ***************************************************************** */
|
|
|
|
|
|
#include <Stepper.h>
|
|
|
|
const int stepsPerRevolution = 2038; // change this to fit the number of steps per revolution
|
|
// for your motor
|
|
|
|
// initialize the stepper library on pins 8 through 11:
|
|
Stepper myStepper_Y(stepsPerRevolution, 14, 16, 15, 17);
|
|
Stepper myStepper_X(stepsPerRevolution, 5, 3, 4, 2);
|
|
|
|
void setup() {
|
|
|
|
myStepper_Y.setSpeed(18);
|
|
myStepper_X.setSpeed(18);
|
|
// initialize the serial port:
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
// step one revolution in one direction:
|
|
Serial.println("clockwise");
|
|
myStepper_Y.step(500);
|
|
myStepper_X.step(500);
|
|
delay(500);
|
|
|
|
// step one revolution in the other direction:
|
|
Serial.println("counterclockwise");
|
|
myStepper_Y.step(-500);
|
|
myStepper_X.step(-500);
|
|
delay(500);
|
|
}
|
|
|