Adventures with an Arduino – Part 3: The solution.

“The circle is now complete.” – Darth Vader.

More Darth Vader quotes. Excellent. To recap, we now have the garage controller interface sorted out and the basics of the Arduino understood. Now, it’s time to complete the circuit design and move on to the build.

This post is part of a 6 part series, starting with Part 1.

The Arduino’s operating voltage is 5V. In order to interface with the Garage Controller, I decided to use a 5V SPST Relay, which allowed me to electrically isolate the Arduino from the Garage Controller. An SPST Relay is a single-pole, single-throw relay. Wikipedia has a great article explaining the difference between SPST, SPDT, DPST, DPDT relays. Put simply however, a relay is a switch – but instead of the switch being activated by someone pushing a button, it’s activated with electronics.

The basic premise of the relay is that when I apply 5V to the relay it generates a magnetic field that closes the relay circuit. In the diagram below, the N.O connector on the relay indicates “Normally Open”. When the magnetic field is generated, the switch in the relay will close, connecting the C (Common) and N.O points together, resulting in PB and C on the Garage Controller being connected. When the 5V is withdrawn the relay will disengage. However at this point, as the magnetic field collapses, the back EMF voltage can generate an electrical spike. The 1N4004 diode has been inserted to allow current to flow back into the relay, rather than back to the Arduino. I purchased both from Jaycar ( The diode only allows DC to pass through one way. So in the diagram below, the DC current can flow up through the diode, but not down. When the spike occurs, the current will flow back through the diode and again into the relay, gradually being absorbed by the resistance inherent in the relay.

Garage Circuit v1.0

We now have a circuit. Now its time to write the Arduino code. I’ll start with basic code that simply triggers the controller every 60 seconds. This will validate that the basic functionality of the circuit is working.


/* Function: setup()  */
void setup()
	// Initialise Serial Port Communications (via USB)


	// Configure Pins

/* Function: loop()   */
void loop()

	Serial.println("Sending Trigger");

	// Activate Relay


	// Reset Relay


That’s it. When the loop() function executes it sets digital pin 7 to HIGH (+5V), waits for 100ms and then sets digital pin 7 back to LOW again. After a further 60 second delay, the process repeats. Other than annoying neighbours, having a garage door that now opens and closes automatically every 60 seconds is a bit pointless. However, I was able to create this circuit on a breadboard and then use a multimeter to measure the continuity across the output pins of the relay. During normal operations the pins showed as open circuit. When the relay became activated by the Arduino the multimeter showed that the output pins were now connected.

Basic Breadboard

The basic breadboard.

 Arduino Garage Circuit

The Arduino with connections to the breadboard.

Breadboard Garage Circuit

The breadboard circuit with the relay, diode, connectivity back to the Arduino, and two relay output wires I could measure with a multimeter.

Ok, so far we have the garage interface, the basic code, and the circuit design completed. Theoretically at this point we could just introduce a push button into the circuit and we would have built another remote control for the garage. However the aim was to control the door from the phone. So now we need to start looking at the networking code.

On to Part 4.

~ Mike

One thought on “Adventures with an Arduino – Part 3: The solution.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s