Netzgeräte mit einem Relais schalten
Schalten Sie eine Lampe oder einen Lüfter über einen Digitalpin.
Netzgeräte mit einem Relais schalten ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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 onActive-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. 🚀
Häufig gestellte Fragen
Ist die Lektion „Netzgeräte mit einem Relais schalten“ kostenlos?
Ja — der vollständige Text von „Netzgeräte mit einem Relais schalten“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Netzgeräte mit einem Relais schalten“?
Schalten Sie eine Lampe oder einen Lüfter über einen Digitalpin. Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?
Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „Netzgeräte mit einem Relais schalten“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?
Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Warum Sie einen Treiber benötigen
- Geschwindigkeit und Richtung mit einer H-Brücke
- Netzgeräte mit einem Relais schalten
- Vor Rückschlagspitzen schützen