Skip to content

Instantly share code, notes, and snippets.

Created Dec 3, 2012
What would you like to do?

#Setting up arduino, computer, and power chord

##Step 1 - cheap power chord Cut it in half. This example deals with a power chord which does NOT have the ground pin.

##Step 2 - connect with Arduino wires Strip off a bit of the insulating cable (.83 inches exactly), twist the wires together, and wrap it around a wire from the Arduino kit. Like so:

##Step 3 - hook up to breadboard The setup is very similar to Circuit #13 in the SIK Guide that came with your Arduino UNO kit. Instead of the resistor in 14b, hook in one of the lines from the plug side of the power chord. And instead of LED in 19c, hook in one of the lines from the other side of the chord. With the remaining lines you connected to the power chord, plug them into their own row (30 in the diagram) to complete the circuit. Note - you could also just have spliced these together...

And here is the finished product in real life:

This doesn't match the breadboard diagram above exactly, I removed some un-needed wires to keep things simpler looking.

  • The diode in the diagram is reversed (good job sparkfun), black end should be facing right.
  • The red and black (5V and GND) lines from the Arduino can go straight to the right side of the breadboard (no need for the orange and green lines then)
  • The magenta line from 15i to 19e could be removed and your power chord line could go straight into 15i itself.

In this way it's almost easy to see how the relay works. All that crap on the top of the breadboard controls the relay, the computer will send 5 volts to it which will close the circuit we've constructed. When the relay is closed, power can flow from our plug end of the power chord, into 14c, through the closed relay, out 15i and over to whatever we're powering!

# Install the dino gem, push the src/du.ino code onto the arduino
# This code will close the relay switch for 2 seconds, then open it for 2 seconds. 5 times.
# You should hear the relay click if everything is set up correctly.
# gem install dino
# ruby led.rb
require 'dino'
board =
led = 2, board: board)
5.times do
sleep 2
sleep 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment