digitalWrite HIGH und LOW
Schalten Sie einen Pin ein und aus, um eine LED leuchten zu lassen
digitalWrite HIGH und LOW ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 2 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.
Now Make It Glow
Your pin is set to OUTPUT, but it is still silent. To actually switch it on or off, you use one new command: digitalWrite. ✨
Two States Only
A digital pin lives in just two states. It is either fully on, called HIGH, or fully off, called LOW. There is nothing in between.
HIGH Means On
Writing HIGH pushes the pin up to roughly 5 volts. That voltage flows through your LED and lights it. HIGH is the on signal.
digitalWrite(ledPin, HIGH);LOW Means Off
Writing LOW drops the pin back to 0 volts. With no voltage to push current, the LED goes dark. LOW is the off signal.
digitalWrite(ledPin, LOW);The Two Arguments
digitalWrite needs two things: which pin to change, and the state to set. So you pass a pin and then either HIGH or LOW.
digitalWrite(pin, HIGH);It Belongs in loop
You set a pin's mode once, but you can change its state any time. Put digitalWrite in loop() to switch the LED on demand.
On Then Off
To blink, you simply alternate. Drive the pin HIGH, then drive it LOW, and the LED toggles between glowing and dark.
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);Too Fast to See
Run HIGH then LOW with nothing between and the LED flickers far too fast for your eyes. You need a pause, which comes next lesson.
1 and 0 Also Work
HIGH and LOW are just friendly names. Under the hood they equal 1 and 0, so digitalWrite(pin, 1) does the same as HIGH.
Read Back the State
digitalWrite changes a pin but never reports it. To check what an output pin is doing, you track the state yourself in a variable.
Mind the Wiring
The onboard LED needs no parts, but an external one can pull too much current. Always protect it with a resistor, covered soon.
Quick Check
Your LED is connected and the pin is OUTPUT. How do you turn it off?
Recap
You now control a pin with digitalWrite, using HIGH for on and LOW for off. Next you will add timing so the blink is actually visible. 🎉
Häufig gestellte Fragen
Ist die Lektion „digitalWrite HIGH und LOW“ kostenlos?
Ja — der vollständige Text von „digitalWrite HIGH und LOW“ 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 „digitalWrite HIGH und LOW“?
Schalten Sie einen Pin ein und aus, um eine LED leuchten zu lassen 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 2 von 4.
Wie lange dauert die Lektion „digitalWrite HIGH und LOW“?
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
- pinMode und OUTPUT
- digitalWrite HIGH und LOW
- delay() und Blinkintervalle
- Eine externe LED sicher anschließen