Posts tagged Garage Door

Posted 1 year ago

Computer Controlled Garage Door Opener

So tonight I had my first lesson in robotics. 

My goal was to be able to open my garage door from my computer using a RS-232 (serial) relay board. 

The Parts:

Assembly:

This was the easy part. Installed the driver for the USB to serial cable. Plugged in the power cable and connected it to the relay board. Connected the serial cable to the relay board and I was all set for testing.

National Control Devices provides a utility to test communication between your computer. I fired it up, selected the relay board type and COM port, and spent a few minutes giggling with glee as I watched the relay’s LEDs toggle on and off as I opened and closed the relays.

Next step was to connect the relay board to the garage door and make it open and close. For my particular Chamberlain garage door, I followed the wire from the button to where it connected to the motor unit. I attached a second wire along side this one to the motor unit, and connected the opposite end to the relay board in the normally open position.

Toggling the relay on and off now made the garage door open and close.

The code

Now all that was left was to program a simple application to send the command to the relay board to close and open the relay.

All of the commands were were nicely outlined in the manual. The commands to turn Relay One on and off are 1 and 0 respectively. In addition all commands must be proceeded with 254 to put the device in “command mode.” 

Here is the code:

public static void Main(string[] args)
{
    SerialPort port = new SerialPort("COM4");
    port.Open();
    port.Write(new byte[] { 254, 1 }, 0, 2);
    Thread.Sleep(100);
    port.Write(new byte[] { 254, 0 }, 0, 2);
    port.Close();
}

Although my garage door appeared to open and close just fine without the Thread.Sleep, I found it more appealing to actually see the LED flash on an off when my program ran, just as a visual confirmation that everything worked as expected.