In this project I would like to RFID my card and after its identification proceed to run stepper motor. But for some reason the motor is not activated. Why? If I use an example sketch for stepper motor the connection is set properly. Here is partial sketch, because the sketch is too long. Please refer to attachment.
else {
if ( isMaster(readCard) ) { // If scanned card's ID matches Master Card's ID enter program mode
programMode = true;
Serial.println("Hello Master - Entered Program Mode");
int count = EEPROM.read(0); // Read the first Byte of EEPROM that
Serial.print("I have "); // stores the number of ID's in EEPROM
Serial.print(count);
Serial.print(" record(s) on EEPROM");
Serial.println("");
Serial.println("Scan a PICC to ADD or REMOVE");
Serial.println("-----------------------------");
//else{
// if(findID(readCard)){ // If not, see if the card is in the EEPROM
Serial.println("Welcome, You shall pass");
/***********************************
COMMAND FOR STEPPER MOTOR
***********************************/
Serial.println("START STEPPER");
if (stepper.isDone() && rotate1 == false)
{
delay(2000);
//Define o sentido de rotacao (CW = Horario)
stepper.setDirection(CW);
//Define o numero de rotacoes
stepper.rotate(2);
rotate1 = true;
delay(2000); // Hold green LED on for 2 more seconds
}
if (stepper.isDone() && rotate1 == true)
{
delay(2000);
//Define o sentido de rotacao (CCW = Anti-horario)
stepper.setDirection(CCW);
//Define o numero de rotacoes
stepper.rotate(2);
rotate1 = false;
}
stepper.run();
openDoor(6000); // Open the door lock for 300 ms
// If not, show that the ID was not valid
Serial.println("You shall not pass");
failed();
}
}
}
RFIDDoorLockVersion1.ino (19.9 KB)