0Pricing
Arduino & IoT Academy · Lección

Conmutar dispositivos de red eléctrica con un relé

Encienda y apague una lámpara o un ventilador desde un pin digital.

Conmutar dispositivos de red eléctrica con un relé es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Controlling Big Things

Sometimes you want your Arduino to switch a lamp or a fan, not just an LED. For mains-powered gear you reach for a relay. 💡

A Relay Is a Switch

A relay is an electrically controlled switch. A small coil current pulls a metal contact closed, connecting a totally separate, much higher-power circuit.

Electrical Isolation

The coil and the contacts never touch electrically. This isolation is why a 5V Arduino can safely command a 220V device without sharing wires.

Use a Relay Module

Grab a ready-made relay module. It already has the driving transistor, a flyback diode, and screw terminals, so you just supply a control signal.

The Three Control Wires

A typical module has three pins: VCC, GND, and a signal input. Connect signal to any Arduino digital pin to control the relay.

Driving It in Code

Treat the relay like an LED. Set the pin HIGH or LOW to close or open the contact, depending on how your module is wired.

int relay = 7;
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH); // switch on

Active-Low Surprise

Many modules are active-low: LOW turns the load on and HIGH turns it off. Test yours so the logic in your sketch matches reality.

NO and NC Terminals

The output side offers NO and NC contacts. Normally Open stays off until triggered; Normally Closed is on until the relay switches.

Wire the Load Through COM

Run one mains wire to the COM terminal and the other to NO. When the relay clicks, the circuit closes and your device powers up.

Respect Mains Safety

Mains voltage can kill. Never touch live terminals, keep the high-voltage side enclosed, and have an adult or pro check anything wired to the wall. ⚠️

Hear the Click

When the relay switches you hear a satisfying click as the coil snaps the contact. That sound confirms your code reached the real world.

Quick Check

What is the main reason a relay is used to switch mains-powered devices from an Arduino?

Recap

A relay is an isolated switch: a small signal closes contacts that power big loads. Use a module, mind active-low logic, and respect mains safety. 🚀

Preguntas frecuentes

¿La lección «Conmutar dispositivos de red eléctrica con un relé» es gratis?

Sí — el texto completo de «Conmutar dispositivos de red eléctrica con un relé» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Conmutar dispositivos de red eléctrica con un relé»?

Encienda y apague una lámpara o un ventilador desde un pin digital. Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Arduino & IoT Academy?

No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.

¿Cuánto tiempo toma la lección «Conmutar dispositivos de red eléctrica con un relé»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?

Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Por qué necesita un controlador
  2. Velocidad y dirección con un puente H
  3. Conmutar dispositivos de red eléctrica con un relé
  4. Protegerse contra picos de retorno
← Volver a Arduino & IoT Academy