Hey guys This is a code for a pneumatic punching machine. works like a 3d printer. 2 steppers on perpendicular axis. it should move as follows: motor 1 move to X location, motor 2 Move to Y location then switch to relay to activate the cylinder and punch, motor 1 move back to the original location, motor 2 move back to original location and repeat for second coordinate and so on, 4 coordinates in total.
last night the code was working but i might have messed something up. i basically need to copy and paste those 5 motions to be able to punch 4 holes into a square sheet. i think the problem is with the copying and placing the second code. help would be appreciated i have just under 5 hours to have this ready to punch 4 holes. help would be much appreciated. Thank you. ps. i know to some of you pros this must be toxic but just let it slide.
// pins numbers
const int stepPin1 = 3;
const int dirPin1 = 4;
const int stepPin2 = 7;
const int dirPin2 = 6;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin1,OUTPUT);
pinMode(dirPin1,OUTPUT);
pinMode(stepPin2,OUTPUT);
pinMode(dirPin2,OUTPUT);
pinMode(LED_BUILTIN,OUTPUT);
}
void loop(){
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
delay(3000);
digitalWrite(4,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <1000; x++) {
digitalWrite(3,LOW);
delayMicroseconds(1000);
digitalWrite(3,HIGH);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(6,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <1000; x++) {
digitalWrite(7,LOW);
delayMicroseconds(1000);
digitalWrite(7,HIGH);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for a second
//////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(4,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <1000; x++) {
digitalWrite(3,HIGH);
delayMicroseconds(1000);
digitalWrite(3,LOW);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(6,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <1000; x++) {
digitalWrite(7,HIGH);
delayMicroseconds(1000);
digitalWrite(7,LOW);
delayMicroseconds(1000);
}
delay(2000); // One second delay
digitalWrite(4,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <5000; x++) {
digitalWrite(3,LOW);
delayMicroseconds(1000);
digitalWrite(3,HIGH);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(6,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <5000; x++) {
digitalWrite(7,LOW);
delayMicroseconds(1000);
digitalWrite(7,HIGH);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for a second
digitalWrite(4,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <5000; x++) {
digitalWrite(3,HIGH);
delayMicroseconds(1000);
digitalWrite(3,LOW);
delayMicroseconds(1000);
}
delay(2000); // One second delay
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
digitalWrite(6,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x <5000; x++) {
digitalWrite(7,HIGH);
delayMicroseconds(1000);
digitalWrite(7,LOW);
delayMicroseconds(1000);
}
delay(2000); // One second delay