Introduction: How to Drive a Relay From an Arduino (Bareduino) Using the Bare Minimum of Components

So i have come up with some ideas for some projects (i may or may not post) that involves relays.

So i get my browser ready and get on to eBay and order me some relays, and wait for delivery .......

I got myself 5 pcs of "JQC-3F 5 Pin SPST Coil Power Relays DC 3V" (I am a noob at this electronics stuff) thinking that the ATMega328 pin out voltage should be able to turn on and off the relay instead of using the more traditional relay module as I like to try and simplify and make things less complicated an boil it down to the bare minimal.

Well that didn't work :(

Step 1: What Do You Need...

1 * JQC-3F 5 Pin SPST Coil Power Relays DC 3V, Currently for the bargain of £2.64 for 10 , free delivery !!! (

1 * Breadboard £0.99 on ebay free delivery (

1 * Arduino board (Or a Bareduino in my case) £6.99 , free and fast delivery(

Some dupont cables , £0.85 for 40 (

and whatever you like to turn on and off, in my case for now just an LED (i'm sure you can find one of them yourself)

Step 2: Hook It Up

Hook it up as above and upload the code from below.

What you see in the image is:

  • 4 AA rechargeable batteries powering the AtMega328.
  • 5V (Red) going to the open relay pin (right hand side of relay).
  • Digital PIN10 (White), hooked up to one ned of the coil.
  • Black Relay cable going to ground.
  • And the last red cable (left of relay) going to the LED which is connected to ground.

So when pin 10 goes hight, the relay connects the 2 red cables and viola !

Initially i didn't get the relay to turn on with just one output pin, so i came up with the idea to just add one more pin (White Digital PIN 9 and Grey Digital PIN 10, Frizing image) and that did the trick.

In the video you see that somehow it can work with just one pin, but i'm not too that will work if you have the micro controller run other things at the same time.

In an effort to run the relay with as little current as possible with 2 PINs, consider messing around with a POT or add some resistors so you bring the coil current down to a minimum so it doesn't pump out 40mAh/PIN :)

Step 3: Code:

#include "LowPower.h"
void setup() {
pinMode(9, OUTPUT); pinMode(10, OUTPUT); }
void loop() {
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);

digitalWrite(9, LOW);
digitalWrite(10, LOW);
LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF); }