Hello Community,
I'm trying to connect a servomotor on Z+ pin of CNC Shield but is not working.
I'm very new with arduino/cnc and I don't know what I'm doing wrong. I tried to find the answer on internet but seems that everyone is using GRBL. I will have four stepper motors in my project (X will be duplicated)
This is my code:
#include<Servo.h>
const int StepX = 2;
const int DirX = 5;
const int StepY = 3;
const int DirY = 6;
const int StepZ = 4;
const int DirZ = 7;
const int speed= 1300;
int currentStepX =0;
int currentStepY =0;
int currentStepZ =0;
//servo settings
Servo myservo;
const byte servoPin = 11; // Z+
byte pos = 0;
void setup() {
Serial.begin(9600); // for monitor log.
pinMode(StepX,OUTPUT);
pinMode(DirX,OUTPUT);
pinMode(StepY,OUTPUT);
pinMode(DirY,OUTPUT);
pinMode(StepZ,OUTPUT);
pinMode( DirZ,OUTPUT);
myservo.attach(11);
}
void loop() {
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
}
Thanks in advance,
Adrian
5 posts - 4 participants