IṢẸ́ ỌNÀ
ẸWÀ ÀTI ÌLERA
IṢẸ́ ỌWỌ́
ÀṢÀ ÀTI ÌTÀN
ÌṢERÉ
ÀYÍKÁ
OÚNJẸ ÀTI OHUN MÍMU
REVERSE ENGINEERING
SÁYẸ́ǸSÌ
ERÉ ÌDÁRAYÁ
ÌMỌ̀-Ẹ̀RỌ
ÀWỌN OHUN WÍWỌ̀
Using Relays — SIK Circuit 13
Ed

Ṣẹ́dá nipasẹ̀

Ed

17. Oṣù Kẹta 2026FI
82
0
0
0
0

Using Relays — SIK Circuit 13

Control a relay with a transistor to switch between two LEDs. Learn about electromechanical switching, SPDT relays, Normally Open vs Normally Closed contacts, and flyback protection.

Ìlànà

1

Parts & Introduction

A relay is an electrically-operated mechanical switch. A small current energizes a coil that physically moves a contact arm, switching a separate circuit. Relays can control high-power devices (motors, lights, appliances) from low-power Arduino signals. This experiment uses an SPDT (Single Pole Double Throw) relay to alternate between two LEDs.

Parts Needed

  • 1x Arduino Uno + USB cable
  • 1x Breadboard
  • 1x SPDT Relay
  • 1x NPN Transistor (P2N2222A)
  • 1x Diode (1N4148)
  • 2x LEDs (different colors)
  • 2x 330Ω Resistors
  • 14x Jumper Wires

Àwọn ohun èlò fún ìgbésẹ̀ yìí:

SparkFun Inventor's Kit - V3.2SparkFun Inventor's Kit - V3.21 ohun èlò

Àwọn irinṣẹ́ tí a nílò:

Computer with Arduino IDEComputer with Arduino IDE
2

Hardware Hookup

Wiring Instructions

Transistor + Relay Coil
  1. Connect transistor Base through 330Ω resistor to Arduino Digital Pin 2.
  2. Connect transistor Emitter to GND.
  3. Connect one side of the relay coil to transistor Collector.
  4. Connect other side of relay coil to 5V.
  5. Flyback Diode: Band (cathode) to 5V, anode to Collector.
Relay Contacts + LEDs
  1. Connect relay COMMON through a 330Ω resistor to 5V.
  2. Connect relay NC (Normally Closed) to LED 1 positive leg.
  3. Connect relay NO (Normally Open) to LED 2 positive leg.
  4. Connect both LED negative legs to GND.

Àwọn ohun èlò fún ìgbésẹ̀ yìí:

SPDT RelaySPDT Relay1 ẹyọ
BreadboardBreadboard1 ẹyọ
Jumper WiresJumper Wires8 ẹyọ
3

Arduino Code

Open the Arduino IDE and upload the following sketch to your Arduino board.

relay.inoarduino
/*
SparkFun Inventor's Kit
Example sketch 13 — RELAYS

Use a transistor to drive a relay, alternating two LEDs.

Hardware connections:
  Transistor BASE through 330 ohm resistor to digital pin 2
  Transistor EMITTER to GND
  Relay coil: one side to COLLECTOR, other to 5V
  Flyback diode: band to 5V, anode to COLLECTOR
  Relay COMMON through 330 ohm to 5V
  Relay NC to LED 1 positive, Relay NO to LED 2 positive
  Both LED negatives to GND

This code is completely free for any use.
*/

const int relayPin = 2;
const int timeDelay = 1000;

void setup()
{
  pinMode(relayPin, OUTPUT);
}

void loop()
{
  digitalWrite(relayPin, HIGH);  // Relay on (COM connects to NO)
  delay(timeDelay);

  digitalWrite(relayPin, LOW);   // Relay off (COM connects to NC)
  delay(timeDelay);
}

Àwọn ohun èlò fún ìgbésẹ̀ yìí:

Arduino Uno R3Arduino Uno R31 ẹyọ

Àwọn irinṣẹ́ tí a nílò:

Computer with Arduino IDEComputer with Arduino IDE
4

Test & Experiment

What You Should See

You should hear the relay clicking, and see the two LEDs alternating — one on, one off — switching every second.

Troubleshooting

  • LEDs not lighting: Check LED polarity — longer leg is positive.
  • No clicking sound: The transistor or coil circuit isn't working. Verify transistor orientation and coil connections.
  • Relay not making good contact: The SIK relay is designed for soldering, not breadboarding. Press it firmly to ensure all pins contact.
  • Confusion: Don't mix up the TMP36 temperature sensor with the transistor!

Experiments to Try

  • Replace the LEDs with a motor on the NO contact — use the relay as a motor on/off switch.
  • Use a button to control when the relay toggles.
  • Add variable delay to create morse code patterns.

Àwọn ohun-èlò

9
  • 1 ohun èlò
    $108.84
  • Breadboardìdá 10%
    1 ẹyọ
    Magento Legacy Storeships internationally
    láti$9.76
  • Jumper Wiresìdá 10%
    8 ẹyọ
    Magento Legacy Storeships internationally
    láti$4.27
  • 1 ẹyọ
    Magento Legacy Storeships internationally
    láti$27.80
  • 1 ẹyọ
    Àyè
  • Àyè
  • 1 ẹyọ
    Àyè
  • 5mm LEDìdá 10%
    2 ẹyọ
    Magento Legacy Storeships internationally
    láti$3.66
  • Àyè

Àwọn irinṣẹ́ tó nílò

1
Àpapọ̀ Ìfojúsùn
Ohun tí ẹni tó ṣe é rà. Àwọn ohun èlò tí kò ní iye owó ni o máa rà níbi tí o bá ti rà á.
$108.84

CC0 Àgbègbè Gbogbogbò

Blueprint yìí ti jáde lábẹ́ CC0. O lè ṣe àdàkọ, yí padà, pín, àti lò láìsí ìyọ̀ǹda.

Ṣàtìlẹ́yìn Olùṣẹ́dá nípa rírà àwọn ọjà nipasẹ̀ Blueprint wọn Ẹ̀san Olùṣẹ́dá tí àwọn Olùtajà gbé kalẹ̀, tàbí ṣẹ̀dá àtúnṣe tuntun ti Blueprint yìí kí o sì fi sínú Blueprint rẹ gẹ́gẹ́ bí ìsopọ̀ láti pín owó-wíwọlé.

Ìfọ̀rọ̀wérọ̀

(0)

Wọlé láti dara pọ̀ mọ́ ìfọ̀rọ̀wérọ̀

Ń gbé àwọn ọ̀rọ̀ wọlé...