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

Picture of 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...

Picture of 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 !!! (http://www.ebay.co.uk/sch/i.html?_from=R40&_sacat=...)

1 * Breadboard £0.99 on ebay free delivery (http://www.ebay.co.uk/sch/i.html?_from=R40&_sacat=...)

1 * Arduino board (Or a Bareduino in my case) £6.99 , free and fast delivery(http://www.ebay.co.uk/itm/Arduino-UNO-R3-328-ATMEG...)

Some dupont cables , £0.85 for 40 (http://www.ebay.co.uk/itm/40-Pcs-Dupont-Jumper-Wir...)

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

Picture of 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); }

Comments

Jsmchiang (author)2016-10-03

Not a good idea. Before you turn the second pin high, the first pin will be shorted to ground from the second pin.

Skorekaj (author)Jsmchiang2016-10-04

Are you sure, i mean the 2 pin is set to output ?

Even if thats the case one could just stick a diod in on the second pin.

About This Instructable

331views

12favorites

License:

More by Skorekaj:Pi 3, 2 the MaX for Under £5 - Overclocking - Automatic 2 Speed Cooling Instant InfraRed Solar Charged ThermometerAll the colours of the RainboW but no RBG LED in sight . . .
Add instructable to: