🐱 Tutorial 15 - Relay

A relay is an electronic device that is used to switch a circuit on or off using a low-power signal. It consists of a coil of wire and one or more sets of contacts that are operated by the coil.

When a current is passed through the coil, it creates a magnetic field that pulls the contacts together, closing the circuit and allowing a larger current to flow through the relay. When the current through the coil is turned off, the magnetic field collapses, and the contacts open, breaking the circuit.

Relays are commonly used in a variety of electronic and electrical applications, such as in industrial control systems, automotive circuits, and home automation systems. They are often used to switch high-power devices, such as motors, lights, and heaters, using a low-power control signal from a microcontroller, switch, or sensor.

There are several types of relays, including electromechanical relays, solid-state relays, and reed relays. Electromechanical relays use a physical switch to open and close the circuit, while solid-state relays use semiconductor devices to perform the switching. Reed relays use a small, sealed glass tube containing a set of contacts that are opened and closed by a magnetic field.

Overall, relays are an important component in electronic and electrical circuits, providing a reliable and efficient way to switch high-power devices using a low-power control signal.

Components Needed

ComponentQuantity
Raspberry Pi Pico W1
Micro USB Cable1
Breadboard1
WiresSeveral
Relay1
Diode1

Fritzing Diagram - Relay

Code

import machine
import utime

relay = machine.Pin(15, machine.Pin.OUT)
while True:
    relay.value(1)
    utime.sleep(2)
    relay.value(0)
    utime.sleep(2)

Code Explanation

Fritzing Diagram - Relay External Power