Electronic circuits · no code

Pushbutton Relay Activation

A small transistor drives a relay, which is a switch moved by an electromagnet. When you press, the relay goes “click” and swaps from a red light to a green one. You see how a weak signal controls a bigger load.

  • LevelBeginner
  • Time25 min
  • Power9 V DC
  • CategoryMotors & robots

Bill of materials

Everything you need to build it, with the reference you will see on the schematic.

Bill of materials
Qty Part Ref.
1 Pushbutton S1
1 4.7 kΩ resistor (yellow-violet-red) R1
1 10 kΩ resistor (brown-black-orange) R2
1 BC547 NPN transistor Q1
1 9 V relay (coil of about 330 Ω, one changeover contact) K1
1 Diode 1N4007 D1
2 470 Ω resistor (yellow-violet-brown) R3, R4
1 green LED D2
1 red LED D3
1 9 V battery with snap clip BT1
1 Breadboard (400 tie-points or more)
7 Jumper wires

Missing parts? The kits recommended by Impeca Tech include almost all of them. See the kits

Schematic & wiring

On the left, the circuit diagram; on the right, the same circuit built on a breadboard. Both connect exactly the same things.

Circuit diagram of “Pushbutton Relay Activation”
Circuit diagram
Breadboard layout of “Pushbutton Relay Activation”
Breadboard layout

Wire it step by step

  1. Place the components
    • Pushbutton S1 straddling the centre channel of the breadboard: two legs on top (3f and 5f) and two below (3e and 5e).
    • 4.7 kΩ resistor R1 (bands: yellow, violet, red, gold): one leg in 6f and the other in 9f (either way round).
    • 10 kΩ resistor R2 (bands: brown, black, orange, gold): one leg in 9g and the other in 12g (either way round).
    • BC547 transistor Q1 with the flat face (the one with the text) towards you, left to right: collector (C) in 13f, base (B) in 14f, emitter (E) in 15f.
    • 1N4007 diode D1: the end with the silver stripe (cathode) in 8i and the other end (anode) in 13i.
    • 470 Ω resistor R3 (bands: yellow, violet, brown, gold): one leg in 19f and the other in 16f (either way round).
    • green LED D2: the long leg (+, anode) in 16h and the short leg (−, cathode, flat side) in 15h.
    • 470 Ω resistor R4 (bands: yellow, violet, brown, gold): one leg in 17h and the other in 20h (either way round).
    • red LED D3: the long leg (+, anode) in 20f and the short leg (−, cathode, flat side) in 21f.
  2. Add the jumper wires
    • Red wire: from 3j to the + (red) rail.
    • Red wire: from 8j to the + (red) rail.
    • Orange wire: from 3d to 6j.
    • Turquoise wire: from 9j to 14j.
    • Black wire: from 12j to the − (blue) rail.
    • Black wire: from 15j to the − (blue) rail.
    • Black wire: from 21j to the − (blue) rail.
  3. Connect the external parts
    • 9 V relay (K1), one wire per terminal: A1 → the + rail; A2 → 13j; COM → the + rail; NO → 19j; NC → 17j.
  4. Connect the battery
    • Connect the 9 V battery to its clip: the clip’s red lead to the + (red) rail and the black one to the − (blue) rail. Do this last, once everything else is in place.
  5. Test the circuit
    • With no press only the red LED should be on. Press S1: you will hear a “click”, the red goes out and the green lights. Release: another “click” and the red returns. With a fresh battery the green and the red shine equally (about 15 mA each). If the green never lights, measure the coil with the multimeter: there should be more than 6.5 V across its two terminals while pressing.

How to read the holes: the letter is the row and the number is the column of the breadboard (for example 7f). The red (+) and blue (−) rails are the two long lines along the edge.

How does it work?

  1. 1With no press, Q1 is off and the relay at rest: the red light is on
  2. 2Pressing S1 sends current to the base of Q1 through R1
  3. 3Q1 conducts and the relay coil magnetises: the contact changes with a “click”
  4. 4The red light goes off and the green one comes on; on release everything returns to rest

Relay K1 has a 9 V coil and a changeover contact with three terminals: COM (common), NC (normally closed) and NO (normally open). At rest COM is joined to NC and powers the red LED. When you press S1, R1 (4.7 kΩ) lets current into the base of Q1; R2 (10 kΩ) holds the base at 0 V when not pressed. Q1 saturates and about 27 mA flows through the coil: it magnetises, COM jumps to NO and the green LED lights (each LED has its own 470 Ω resistor, about 15 mA). Diode D1 (1N4007) sits backwards across the coil: when Q1 turns off, the coil tries to keep the current flowing and makes a voltage spike that could damage Q1; D1 gives it a path and absorbs it. Important: with a nearly flat 9 V battery (below about 7.5 V) the relay may not pull in properly; replace it. In this circuit the relay contacts only drive LEDs: never connect them to household mains.

Testing & troubleshooting

What you should see

Button released: relay at rest
Red LED current (NC contact)≈ 15 mA
Green LED current (NO contact)under 0.1 mA
Button pressed: relay energised
Green LED current (NO contact)≈ 15 mA
Red LED current (NC contact)under 0.1 mA
Relay coil current≈ 27 mA
Coil voltage≈ 8.87 V

Approximate values, calculated with typical parts. With real parts they can vary by 10 % or more.

If something does not work

The relay does not click when I press

It is almost always the battery: below about 7.5 V the coil does not pull in well. Try a fresh battery. Then check that Q1 faces as in the drawing (C, B, E in order) and that R1 and R2 are in the right rows.

The relay clicks but the LEDs do not change

The LEDs are backwards or wired to the wrong NO and NC terminals. The long leg (anode) goes towards the 470 Ω resistor. Check on the drawing which relay terminal is COM, NO and NC; they are marked on the relay body.

The relay stays on and will not release

R2 is not properly connected between the base of Q1 and GND, or is missing: without it the base “floats” and may stay on. Also check there is no stray wire joining the base to the positive.

Want to automate this circuit with code?

Learn how to program sensors and custom schedules in our e-book “Arduino from Scratch”.