Pneumatic Door Control
Home Automation
If you have read and followed my other projects, you would know that I am a Star Trek fan. I was always fascinated by the automatic doors and the 'air' sound they made. I have some pneumatic components that are left overs from another project. So, I will be documenting my progress here. I'm not saying that is going to be an exact replica of any of the Enterprise's doors, but just a simple system to automate a regular door.
I wanted the door to be able to open, close and lock, unlock with just a key press. Also be able to control via phone through bluetooth, and some push buttons for redundancy. So won't be going into details and tutorials since there is a ton of those across the net. If there is some interest in a certain feature, I might write up a tutorial about that feature. I'll list the features, components, software for your use if you choose.
For the pneumatic components, you can find a lot of these used on Ebay. The cylinders were $10-$20 each. The electronic valves were the expensive part. For the air lines, I'm using 4mm plastic tubing along with 4mm push fittings. Then you need an air compressor and tank. The compressor I have is a cheap $20 air pump that I found on Ebay a while back. To regulate the pressure, I'm using a electronic pressure switch from Amazon.
# | Name | Value | Source | Description |
---|---|---|---|---|
1 | Arduino Pro Mini | NA | Amazon | Description |
2 | Relays | 250V |
Amazon Amazon |
Single Channel Module 8-Channel Relay Module |
3 | Wireless Relay | 4-Channel | Amazon | Wireless 4-Channel Relay with Key Fob |
//
//Code by Trevor @RoosRobotics.com
// 9-11-21
// Inital version
// Implemented Door Lock function
// 9-14-21
// Added Keypad Functionality
// Added function to automatically close door after it has opened
// 9-26-21
// Added LEDs for LOCK_STATUS - Green = Unlocked, Red = Locked
// 9-31-21
// Updated RemoteXY library
// 10-2-21
// GUI redesign
// Bug fixes (mainly hardware)
// 10-4-21
// Added logic to check lock status & if it's locked, unlock it first then open door
// 10-6-21
// Key 2 not working. maybe change pins from analog to digital??
// 10-9-21
// Changed to analog pin
// 10-20-21
// Added wireless fob function [KEY_OPEN & KEY_CLOSE]
/*
-- Home Automation --
This source code of graphical user interface
has been generated automatically by RemoteXY editor.
To compile this code using RemoteXY library 3.1.6 or later version
download by link http://remotexy.com/en/library/
To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- for ANDROID 4.8.01 or later version;
- for iOS 1.5.1 or later version;
This source code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
*/
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL
#include
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 9600
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255, 4, 0, 10, 0, 251, 0, 13, 24, 1,
130, 1, 3, 12, 57, 31, 26, 65, 121, 36,
31, 21, 9, 1, 1, 8, 20, 18, 7, 30,
242, 79, 112, 101, 110, 0, 1, 1, 37, 20,
19, 7, 30, 242, 67, 108, 111, 115, 101, 0,
129, 0, 27, 13, 9, 4, 24, 68, 111, 111,
114, 0, 65, 65, 9, 16, 16, 2, 65, 65,
38, 16, 17, 2, 1, 1, 38, 33, 17, 5,
9, 31, 76, 111, 99, 107, 0, 65, 121, 7,
31, 20, 9, 1, 9, 9, 33, 16, 5, 4,
31, 85, 110, 108, 111, 99, 107, 0, 129, 0,
14, 5, 36, 4, 159, 82, 111, 115, 115, 82,
111, 98, 111, 116, 105, 99, 115, 46, 99, 111,
109, 0, 129, 0, 17, 96, 30, 3, 26, 68,
101, 115, 105, 103, 110, 101, 100, 32, 66, 121,
58, 32, 84, 114, 101, 118, 111, 114, 0, 129,
0, 7, 78, 14, 3, 24, 68, 101, 115, 107,
32, 76, 69, 68, 0, 129, 0, 24, 78, 16,
3, 24, 68, 101, 115, 107, 32, 76, 97, 109,
112, 0, 130, 1, 2, 78, 59, 16, 28, 130,
1, 22, 79, 17, 14, 27, 129, 0, 24, 87,
13, 2, 24, 68, 111, 111, 114, 32, 76, 111,
99, 107, 101, 100, 0, 65, 73, 26, 90, 8,
2, 129, 0, 23, 80, 15, 2, 24, 68, 111,
111, 114, 32, 85, 110, 108, 111, 99, 107, 101,
100, 0, 65, 41, 26, 83, 8, 2
};
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t Door_open; // =1 if button pressed, else =0
uint8_t Door_close; // =1 if button pressed, else =0
uint8_t button_lock; // =1 if button pressed, else =0
uint8_t button_unlock; // =1 if button pressed, else =0
// output variables
uint8_t lock_rgb_r; // =0..255 LED Red brightness
uint8_t lock_rgb_g; // =0..255 LED Green brightness
uint8_t lock_rgb_b; // =0..255 LED Blue brightness
uint8_t led_open_r; // =0..255 LED Red brightness
uint8_t led_close_r; // =0..255 LED Red brightness
uint8_t unlock_rgb_r; // =0..255 LED Red brightness
uint8_t unlock_rgb_g; // =0..255 LED Green brightness
uint8_t unlock_rgb_b; // =0..255 LED Blue brightness
uint8_t lockstatus_en_r; // =0..255 LED Red brightness
uint8_t lockstatus_un_g; // =0..255 LED Green brightness
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#include
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte pin_rows[ROW_NUM] = {A3, A2, A1, A0}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {13, 12, 11}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
#define PIN_DOOR_OPEN 4
#define PIN_DOOR_CLOSE 5
#define PIN_BUTTON_LOCK 7
#define PIN_BUTTON_UNLOCK 6
#define DOOR_UNLOCKED 9
#define DOOR_LOCKED 8
#define DOOR_LOCK_STATUS 10
int DOOR_LOCK_STATE;
#define KEY_OPEN A5
#define KEY_CLOSE A4
void setup()
{
RemoteXY_Init ();
pinMode (PIN_DOOR_OPEN, OUTPUT);
pinMode (PIN_DOOR_CLOSE, OUTPUT);
pinMode (PIN_BUTTON_LOCK, OUTPUT);
pinMode (PIN_BUTTON_UNLOCK, OUTPUT);
pinMode (DOOR_LOCK_STATUS, INPUT); //HIGH == LOCKED, LOW == UNLOCKED
pinMode (DOOR_LOCKED, OUTPUT); // RED LED
pinMode (DOOR_UNLOCKED, OUTPUT);// GREEN LED
pinMode (KEY_OPEN, OUTPUT); //Dedicated pins for
pinMode (KEY_CLOSE, OUTPUT); //wireless FOB
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_DOOR_OPEN, (RemoteXY.Door_open == 0) ? HIGH : LOW);
digitalWrite(PIN_DOOR_CLOSE, (RemoteXY.Door_close == 0) ? HIGH : LOW);
digitalWrite(PIN_BUTTON_LOCK, (RemoteXY.button_lock == 0) ? HIGH : LOW);
digitalWrite(PIN_BUTTON_UNLOCK, (RemoteXY.button_unlock == 0) ? HIGH : LOW);
//****************Keypad Logic*****************//
char key = keypad.getKey();
if (key) {
///checks door lock status, and if it's 'locked', Unlocks, then opens door
//Keypad "1" will leave the door open
if ((key == '1') && (digitalRead(DOOR_LOCK_STATUS) == LOW)) {
digitalWrite (PIN_BUTTON_UNLOCK, LOW);
delay(20);
digitalWrite (PIN_BUTTON_UNLOCK, HIGH);
delay(50);
digitalWrite(PIN_DOOR_OPEN, LOW);
delay (20);
digitalWrite(PIN_DOOR_OPEN, HIGH);
}
//Door unlocked? just open door
if ((key == '1') && (digitalRead(DOOR_LOCK_STATUS) == HIGH)){
digitalWrite(PIN_DOOR_OPEN, LOW);
delay (20);
digitalWrite(PIN_DOOR_OPEN, HIGH);
}
if (key == '2') { //Keypad "2" will close the door after the set time
digitalWrite(PIN_DOOR_OPEN, LOW);
delay(20);
digitalWrite(PIN_DOOR_OPEN, HIGH);
//delays are fine since we're walking through the door and not doing anything else
delay(3000);
digitalWrite(PIN_DOOR_CLOSE, LOW);
delay(20);
digitalWrite(PIN_DOOR_CLOSE, HIGH);
}
}
/* *****************Door lock status***************************** */
if (digitalRead(DOOR_LOCK_STATUS) == HIGH) {
digitalWrite(DOOR_LOCKED, HIGH); //turns on LED on keypad
digitalWrite(DOOR_UNLOCKED, LOW);
RemoteXY.lock_rgb_r = 255;
RemoteXY.lock_rgb_g = 0;
RemoteXY.unlock_rgb_r = 0;
RemoteXY.unlock_rgb_g = 255;
}
else {
digitalWrite(DOOR_UNLOCKED, HIGH);
digitalWrite(DOOR_LOCKED, LOW);
RemoteXY.lock_rgb_r = 0;
RemoteXY.lock_rgb_g = 255;
RemoteXY.unlock_rgb_g = 0;
RemoteXY.unlock_rgb_r = 255;
}
}