Relay Circuit

Hey, I want to test a relay circuit which is a final process of my project and I am stuck on it, I followed the relay schematics as given playground.arduino.cc/uploads/Learning/relays.pdf, and made sure that everything is correct, but still its not working.

I used 6v external power source for relay (also for led which is driven by relay), connected positive to relay through a 1N4007 diode and then GND of a relay through (1N4007 diode) to the (1N2222) transistor`s collector and then emitter to the GND of adruino and the power supply (common), the base of transistor is connected to the arduino digital output 2 via 1k resistor.

Further, an led is also connected to relay with NC pin and GND to the arduino and power supply (common). The power supply is the same for both led and relay, so I made GND common.

check this video for more details

but its not working, could you please check what did I do wrong?

and I am sure its not programming fault as I used a simple code of digital.write high and low.

Thank you

Nobody can discern your circuit from that video.... nor can we see your code....

Hi, the video is not the best way to show your project, try a few pictures, I can see for a start that one of the leads on the transistor is not connected to anything.
Also what is the relay you are using .
Tom... :slight_smile:

TomGeorge:
Hi, the video is not the best way to show your project, try a few pictures, I can see for a start that one of the leads on the transistor is not connected to anything.
Also what is the relay you are using .
Tom... :slight_smile:

rofl, I got it right that mistake, but still not working, I am sure I messed up some wiring, I am using 6v relay (OEG PCE-106D1H), Just tell me that the component I am using with the relay is ok?

JimboZA:
Nobody can discern your circuit from that video.... nor can we see your code....

here is the code, I extracted it from the example library.

/*
  contact
  Turns on relay on for five second, then off for five second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 2 has a relay connected to an LED.
// give it a name:
int relay = 2;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(relay, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(relay, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(5000);               // wait for 5 second
  digitalWrite(relay, LOW);    // turn the LED off by making the voltage LOW
  delay(5000);               // wait for 5 second
}

Hi, okay, now some pictures of your project, that way we can check your layout.
So far so good..
Tom.. :slight_smile:

I'm not sure what you mean when you say the connections are "through" the diode: the diode is in parallel with the relay, and I can't really check that from the video even if I pause. Also, since the diode is a fly-back, it must be connected back-to-front, ie cathode to the positive supply.

Other than that, double check the transistor for being connected the right way....

JimboZA:
I'm not sure what you mean when you say the connections are "through" the diode: the diode is in parallel with the relay, and I can't really check that from the video even if I pause. Also, since the diode is a fly-back, it must be connected back-to-front, ie cathode to the positive supply.

Other than that, double check the transistor for being connected the right way....

TomGeorge:
Hi, okay, now some pictures of your project, that way we can check your layout.
So far so good..
Tom.. :slight_smile:

JimboZA:
Nobody can discern your circuit from that video.... nor can we see your code....

here are the pictures, I made the circuit again as per relay schematic given before, I hope this helps.

Transistor = 2N2222
Diode = 1N4007
Relay= 6v (OEG PCE-106D1H)

Your code talks of pin 2, the wire's on pin 8

JimboZA:
Your code talks of pin 2, the wire's on pin 8

I know that, I changed it to pin 8, its no problem, I,ll fix the code, I created the circuit again to take pictures, beside, is the circuit correct?

Arsalan:

JimboZA:
Your code talks of pin 2, the wire's on pin 8

I know that, I changed it to pin 8, its no problem, I,ll fix the code, I created the circuit again to take pictures, beside, is the circuit correct?

As a matter of "forum protocol" you should make your posted code and posted pix match, else you are going to have annoyed members trying to help you and identifying things you already fixed.

The circuit looks ok to me except I don't see any power to the Arduino?

(And what happened to the wires?.... you using a tin opener to strip them? :P)

Have you tested the relay?- if you stick 6v across it manually does it switch?

And are your sure that red wire with the rip in the insulation, is in fact conducting?

JimboZA:
Have you tested the relay?- if you stick 6v across it manually does it switch?

And are your sure that red wire with the rip in the insulation, is in fact conducting?

ROFL, dude, I am a mechanical engineer, never studied electronics - in fact never interested, but now I do - so spare me for some mistakes :blush: I just made this circuit so didnt test it, I,ll update you guys after couple of hours after testing.

and thank you for the help, I appreciate it.

Got it, I got it solved, it was a silly mistake, the breadboard is actually divided into two half and I didnt know that so my circuit was divided into two half.. :smiley: I wasnt even supplying the external power, this got me crazy for a whole day, I finally tested it step by step.

thanks everybody for help, appreciate it, that is why I chose arduino, there is a big community out there for help.

Arsalan:
Got it, I got it solved, it was a silly mistake, the breadboard is actually divided into two half and I didnt know that so my circuit was divided into two half.. :smiley: I wasnt even supplying the external power, this got me crazy for a whole day, I finally tested it step by step.

thanks everybody for help, appreciate it, that is why I chose arduino, there is a big community out there for help.

Oh crap! I should have thought of that- it's happened to me and it was the solution in another thread just the other day.

But glad you're sorted

Hi, how did we let that happen, it was staring us in the face in black and white full colour.

Tom... :sleeping:

Oh wow 2n2222 tin can!!!!