Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Self Locking Door Code
- //Reference Ahmad Shamshiri for Robojax.com for Base Code
- //This is modified from Ahmad's Code on controlling a linear actuator
- //This self-locking door code will lock a deadbolt on a door after a certain set time once the Arduino has been turned on.
- //A limit switch will be tied into the power circuit for the Arduino.
- //There are no traditional inputs at this time for this code.
- //Written by Jonathan DeWitt on 6/28/2021 Rev 0 of Code
- const int relay1 = 2;
- const int relay2 = 3;
- int extdT = 1000; //Time the Linear Actuator is Extended (stands for extension delay time)
- int drcldT = 10000; //The time after the door closes (limit switch in power circuit closes) before the linear actuator locks the deadbolt (stands for door close delay time)
- int actactiondT = 2000; //Time given to actuator to fully extend and fully retract (stands for actuator action delay time)
- void actuatorPull();
- void actuatorPush();
- void turnOFF();
- void setup() {
- // put your setup code here, to run once:
- pinMode(relay1, OUTPUT);// set pin as output for relay 1
- pinMode(relay2, OUTPUT);// set pin as output for relay 2
- Serial.begin(9600);// initialize serial monitor with 9600 baud
- //Door Locking Sequence
- delay(drcldT); //Prevents door locking sequence from occuring for a certain amount of time
- actuatorPull(); //Extends the Linear Actuator - Locking the Deadbolt
- delay(actactiondT); //Time needed to extend
- delay(extdT); //Leaves the Linear Actuator Extended for a Certain Amount of Time
- actuatorPush(); //Retracts the Linar Actuator - So it doesn't interfere with the key
- delay(actactiondT); //Time needed to retract
- turnOFF(); //Turns the relays off
- }
- void loop() {
- // put your main code here, to run repeatedly:
- }
- //Function Definitions - Functions Written by Robojax
- void actuatorPush()
- {
- // Robojax Actuator code https://youtu.be/_bkNOyPElOo
- digitalWrite(relay1, LOW);// turn relay 1 ON
- digitalWrite(relay2, HIGH);// turn relay 2 OFF
- }//actuatorPush()
- void actuatorPull()
- {
- // Robojax Actuator code https://youtu.be/_bkNOyPElOo
- digitalWrite(relay1, HIGH);// turn relay 1 OFF
- digitalWrite(relay2, LOW);// turn relay 2 ON
- }//actuatorPull()
- void turnOFF()
- {
- // Robojax Actuator code https://youtu.be/_bkNOyPElOo
- digitalWrite(relay1, HIGH);// turn relay 1 OFF
- digitalWrite(relay2, HIGH);// turn relay 2 OFF
- }//turnOFF()
Add Comment
Please, Sign In to add comment