Steppermotor driven door keylock / keyunlock
thingiverse
int stepperDirectionPin = 2; // Assign a unique ID to the direction pin int stepperStepPin = 3; // Designate the stepper motor's specific connection int stepperEnablePin = 7; // Identify the enable pin for the motor control bool directionIndicator = false; // Initialize a flag to track direction void setup() { initializeMotor(false); } void initializeMotor(bool value) { pinMode(stepperDirectionPin, OUTPUT); // Set the direction pin as an output pinMode(stepperStepPin, OUTPUT); // Designate the stepper motor's specific connection as an output pinMode(stepperEnablePin, OUTPUT); // Identify the enable pin for the motor control as an output if (value) { directionIndicator = !directionIndicator; } else { pinMode(4, INPUT_PULLUP); } } void loop() { if (!digitalRead(4)) { // Check the state of the input from digital pin 4 disableMotor(); // Disable the motor by setting its enable pin low setDirection(directionIndicator ? HIGH : LOW); // Set the direction based on the flag for (int i = 0; i < 23050; i++) { // Perform a series of steps digitalWrite(stepperStepPin, HIGH); // Set the step pin high to initiate a step delayMicroseconds(150); // Delay briefly between steps digitalWrite(stepperStepPin, LOW); // Set the step pin low to complete the step delayMicroseconds(150); // Delay briefly after completing each step } enableMotor(); // Re-enable the motor by setting its enable pin high initializeMotor(true); } } void setDirection(int value) { digitalWrite(stepperDirectionPin, value); } void disableMotor() { digitalWrite(stepperEnablePin, LOW); } void enableMotor() { digitalWrite(stepperEnablePin, HIGH); }
With this file you will be able to print Steppermotor driven door keylock / keyunlock with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Steppermotor driven door keylock / keyunlock.