Hi all,
I thought this was an easy one, but this button has me stumped.
using mega 2560 + ramps1.4
I'm trying to get a two prong tactile button on a breadboard to activate a function called engage(), which turns a nema17 180deg.
So, I placed the tactile button between pin A9/D63 & grnd, named it 'b1'. I've tried both A9 & 63 for pins, plus a few others on the AUX1, 2 & 3. The following happens:
- the y motor seems to be revving but it doesn't move & the heat sink gets hot
- if I touch the 63 pin with a wire without even connecting it to anything the sequence begins
- when pressing the button nothing happens, it seams the button isn't even recognised
- when I remove the 'if statement' to execute the engage() function the motor sequence is good
I was hoping to just create separate sequences and press a separate button for each to call the function but no go.
Any help much appreciated.... here is the code
// Define Motor Pins
const int M1X_stepPin = 54;
const int M1X_dirPin = 55;
const int M1X_enablePin = 38;
const int M1X_optoMinSen = 3;
const int M2Y_stepPin = 60;
const int M2Y_dirPin = 61;
const int M2Y_enablePin = 56;
const int M2Y_optoMinSen = 14;
const int M3Z_stepPin = 46;
const int M3Z_dirPin = 48;
const int M3Z_enablePin = 62;
const int M3Z_optoMinSen = 18;
const int M5E1_stepPin = 36;
const int M5E1_dirPin = 34;
const int M5E1_enablePin = 30;
// Define Button Pins
const int b1 = 63;
const int b2 = 58;
const int b3 = 59;
// Define Air Solenoid Pins
int A1Sol = 57;
//int A1Sen = ##;
//M1X = LeverMotor
float currentM1XAngle = 0;
int M1XAngle = 0;
float stepPerM1XAngle = 1.8; // full step = 1.8
int M1Xnumstep;
//M2Y = CoreMotor
float currentM2YAngle = 0;
int M2YAngle = 0;
float stepPerM2YAngle = 1.8;
int M2Ynumstep;
//M5E1 = RollMotor
float currentM5E1Angle = 0;
int M5E1Angle = 0;
float stepPerM5E1Angle = 1.8;
int M5E1numstep;
// Bring in the functions
void Engage();
void Disengage();
void RemovePape();
void setup() {
Serial.begin(9600);
// Set Motor Pins
pinMode(M1X_stepPin,OUTPUT);
pinMode(M1X_dirPin,OUTPUT);
pinMode(M1X_enablePin, OUTPUT);
pinMode(M1X_optoMinSen, INPUT);
digitalWrite(M1X_enablePin, LOW);
pinMode(M2Y_stepPin,OUTPUT);
pinMode(M2Y_dirPin,OUTPUT);
pinMode(M2Y_enablePin, OUTPUT);
pinMode(M2Y_optoMinSen, INPUT);
digitalWrite(M2Y_enablePin, LOW);
pinMode(M3Z_stepPin,OUTPUT);
pinMode(M3Z_dirPin,OUTPUT);
pinMode(M3Z_enablePin, OUTPUT);
pinMode(M3Z_optoMinSen, INPUT);
digitalWrite(M3Z_enablePin, LOW);
pinMode(M5E1_stepPin,OUTPUT);
pinMode(M5E1_dirPin,OUTPUT);
pinMode(M5E1_enablePin, OUTPUT);
// Set Solenoid Pins
pinMode(A1Sol, OUTPUT);
//pinMode(A1Sen, INPUT);
// Set Button pins
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
}
void loop() {
if (digitalRead(b1) == HIGH) {
Engage();
}
//if (digitalRead(b2) == HIGH) {
//Disengage();
//}
//if (digitalRead(b3) == HIGH) {
//RemovePape();
//}
}